Class: ChatMessage::IssueMessage

Inherits:
BaseMessage show all
Defined in:
app/models/project_services/chat_message/issue_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) ⇒ IssueMessage

Returns a new instance of IssueMessage.


12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/models/project_services/chat_message/issue_message.rb', line 12

def initialize(params)
  super

  obj_attr = params[:object_attributes]
  obj_attr = HashWithIndifferentAccess.new(obj_attr)
  @title = obj_attr[:title]
  @issue_iid = obj_attr[:iid]
  @issue_url = obj_attr[:url]
  @action = obj_attr[:action]
  @state = obj_attr[:state]
  @description = obj_attr[:description] || ''
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action


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

def action
  @action
end

#descriptionObject (readonly)

Returns the value of attribute description


10
11
12
# File 'app/models/project_services/chat_message/issue_message.rb', line 10

def description
  @description
end

#issue_iidObject (readonly)

Returns the value of attribute issue_iid


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

def issue_iid
  @issue_iid
end

#issue_urlObject (readonly)

Returns the value of attribute issue_url


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

def issue_url
  @issue_url
end

#stateObject (readonly)

Returns the value of attribute state


9
10
11
# File 'app/models/project_services/chat_message/issue_message.rb', line 9

def state
  @state
end

#titleObject (readonly)

Returns the value of attribute title


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

def title
  @title
end

Instance Method Details

#activityObject


32
33
34
35
36
37
38
39
# File 'app/models/project_services/chat_message/issue_message.rb', line 32

def activity
  {
    title: "Issue #{state} by #{user_combined_name}",
    subtitle: "in #{project_link}",
    text: issue_link,
    image: user_avatar
  }
end

#attachmentsObject


25
26
27
28
29
30
# File 'app/models/project_services/chat_message/issue_message.rb', line 25

def attachments
  return [] unless opened_issue?
  return description if markdown

  description_message
end