Class: ChatMessage::WikiPageMessage

Inherits:
BaseMessage show all
Defined in:
app/models/project_services/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.


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/project_services/chat_message/wiki_page_message.rb', line 10

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]

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

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action


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

def action
  @action
end

#descriptionObject (readonly)

Returns the value of attribute description


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

def description
  @description
end

#titleObject (readonly)

Returns the value of attribute title


5
6
7
# File 'app/models/project_services/chat_message/wiki_page_message.rb', line 5

def title
  @title
end

#wiki_page_urlObject (readonly)

Returns the value of attribute wiki_page_url


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

def wiki_page_url
  @wiki_page_url
end

Instance Method Details

#activityObject


34
35
36
37
38
39
40
41
# File 'app/models/project_services/chat_message/wiki_page_message.rb', line 34

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

#attachmentsObject


28
29
30
31
32
# File 'app/models/project_services/chat_message/wiki_page_message.rb', line 28

def attachments
  return description if markdown

  description_message
end