Class: Integrations::ChatMessage::PushMessage

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

Returns a new instance of PushMessage.



12
13
14
15
16
17
18
19
20
# File 'app/models/integrations/chat_message/push_message.rb', line 12

def initialize(params)
  super

  @after = params[:after]
  @before = params[:before]
  @commits = params.fetch(:commits, [])
  @ref_type = Gitlab::Git.tag_ref?(params[:ref]) ? 'tag' : 'branch'
  @ref = Gitlab::Git.ref_name(params[:ref])
end

Instance Attribute Details

#afterObject (readonly)

Returns the value of attribute after.



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

def after
  @after
end

#beforeObject (readonly)

Returns the value of attribute before.



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

def before
  @before
end

#commitsObject (readonly)

Returns the value of attribute commits.



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

def commits
  @commits
end

#refObject (readonly)

Returns the value of attribute ref.



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

def ref
  @ref
end

#ref_typeObject (readonly)

Returns the value of attribute ref_type.



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

def ref_type
  @ref_type
end

Instance Method Details

#activityObject



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

def activity
  {
    title: humanized_action(short: true),
    subtitle: "in #{project_link}",
    text: compare_link,
    image: user_avatar
  }
end

#attachmentsObject



22
23
24
25
26
27
# File 'app/models/integrations/chat_message/push_message.rb', line 22

def attachments
  return [] if new_branch? || removed_branch?
  return commit_messages if markdown

  commit_message_attachments
end