Class: ChatMessage::PushMessage

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


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

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


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

def after
  @after
end

#beforeObject (readonly)

Returns the value of attribute before


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

def before
  @before
end

#commitsObject (readonly)

Returns the value of attribute commits


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

def commits
  @commits
end

#refObject (readonly)

Returns the value of attribute ref


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

def ref
  @ref
end

#ref_typeObject (readonly)

Returns the value of attribute ref_type


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

def ref_type
  @ref_type
end

Instance Method Details

#activityObject


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

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

#attachmentsObject


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

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

  commit_message_attachments
end