Class: Integrations::ChatMessage::WikiPageMessage

Inherits:
BaseMessage
  • Object
show all
Defined in:
app/models/integrations/chat_message/wiki_page_message.rb

Constant Summary

Constants inherited from BaseMessage

BaseMessage::RELATIVE_LINK_REGEX

Instance Attribute Summary collapse

Attributes inherited from BaseMessage

#markdown, #project_name, #project_url, #user_avatar, #user_full_name, #user_name

Instance Method Summary collapse

Methods inherited from BaseMessage

#fallback, #pretext, #summary, #user_combined_name

Constructor Details

#initialize(params) ⇒ WikiPageMessage

Returns a new instance of WikiPageMessage.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/integrations/chat_message/wiki_page_message.rb', line 12

def initialize(params)
  super

  obj_attr = params[:object_attributes]
  obj_attr = HashWithIndifferentAccess.new(obj_attr)
  @title = obj_attr[:title]
  @wiki_page_url = obj_attr[:url]
  @description = obj_attr[:message]
  @diff_url = obj_attr[:diff_url]

  @action =
    case obj_attr[:action]
    when "create"
      "created"
    when "update"
      "edited"
    end
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



8
9
10
# File 'app/models/integrations/chat_message/wiki_page_message.rb', line 8

def action
  @action
end

#descriptionObject (readonly)

Returns the value of attribute description.



9
10
11
# File 'app/models/integrations/chat_message/wiki_page_message.rb', line 9

def description
  @description
end

#diff_urlObject (readonly)

Returns the value of attribute diff_url.



10
11
12
# File 'app/models/integrations/chat_message/wiki_page_message.rb', line 10

def diff_url
  @diff_url
end

#titleObject (readonly)

Returns the value of attribute title.



6
7
8
# File 'app/models/integrations/chat_message/wiki_page_message.rb', line 6

def title
  @title
end

#wiki_page_urlObject (readonly)

Returns the value of attribute wiki_page_url.



7
8
9
# File 'app/models/integrations/chat_message/wiki_page_message.rb', line 7

def wiki_page_url
  @wiki_page_url
end

Instance Method Details

#activityObject



37
38
39
40
41
42
43
44
# File 'app/models/integrations/chat_message/wiki_page_message.rb', line 37

def activity
  {
    title: "#{strip_markup(user_combined_name)} #{action} #{wiki_page_link}",
    subtitle: "in #{project_link}",
    text: strip_markup(title),
    image: user_avatar
  }
end

#attachmentsObject



31
32
33
34
35
# File 'app/models/integrations/chat_message/wiki_page_message.rb', line 31

def attachments
  return description if markdown

  description_message
end