Class: Integrations::ChatMessage::MergeMessage

Inherits:
BaseMessage
  • Object
show all
Defined in:
app/models/integrations/chat_message/merge_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) ⇒ MergeMessage

Returns a new instance of MergeMessage.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/integrations/chat_message/merge_message.rb', line 13

def initialize(params)
  super

  obj_attr = params[:object_attributes]
  obj_attr = HashWithIndifferentAccess.new(obj_attr)
  @merge_request_iid = obj_attr[:iid]
  @source_branch = obj_attr[:source_branch]
  @target_branch = obj_attr[:target_branch]
  @action = obj_attr[:action]
  @state = obj_attr[:state]
  @title = format_title(obj_attr[:title])
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



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

def action
  @action
end

#merge_request_iidObject (readonly)

Returns the value of attribute merge_request_iid.



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

def merge_request_iid
  @merge_request_iid
end

#source_branchObject (readonly)

Returns the value of attribute source_branch.



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

def source_branch
  @source_branch
end

#stateObject (readonly)

Returns the value of attribute state.



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

def state
  @state
end

#target_branchObject (readonly)

Returns the value of attribute target_branch.



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

def target_branch
  @target_branch
end

#titleObject (readonly)

Returns the value of attribute title.



11
12
13
# File 'app/models/integrations/chat_message/merge_message.rb', line 11

def title
  @title
end

Instance Method Details

#activityObject



30
31
32
33
34
35
36
37
# File 'app/models/integrations/chat_message/merge_message.rb', line 30

def activity
  {
    title: "Merge request #{state_or_action_text} by #{strip_markup(user_combined_name)}",
    subtitle: "in #{project_link}",
    text: merge_request_link,
    image: user_avatar
  }
end

#attachmentsObject



26
27
28
# File 'app/models/integrations/chat_message/merge_message.rb', line 26

def attachments
  []
end