Class: Integrations::ChatMessage::AlertMessage

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

#activity, #fallback, #pretext, #summary, #user_combined_name

Constructor Details

#initialize(params) ⇒ AlertMessage

Returns a new instance of AlertMessage.



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

def initialize(params)
  @project_name = params[:project_name] || params.dig(:project, :path_with_namespace)
  @project_url = params.dig(:project, :web_url) || params[:project_url]
  @title = params.dig(:object_attributes, :title)
  @alert_url = params.dig(:object_attributes, :url)
  @severity = params.dig(:object_attributes, :severity)
  @events = params.dig(:object_attributes, :events)
  @status = params.dig(:object_attributes, :status)
  @started_at = params.dig(:object_attributes, :started_at)
end

Instance Attribute Details

#alert_urlObject (readonly)

Returns the value of attribute alert_url.



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

def alert_url
  @alert_url
end

#eventsObject (readonly)

Returns the value of attribute events.



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

def events
  @events
end

#severityObject (readonly)

Returns the value of attribute severity.



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

def severity
  @severity
end

#started_atObject (readonly)

Returns the value of attribute started_at.



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

def started_at
  @started_at
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#attachmentsObject



24
25
26
27
28
29
30
31
# File 'app/models/integrations/chat_message/alert_message.rb', line 24

def attachments
  [{
    title: strip_markup(title),
    title_link: alert_url,
    color: attachment_color,
    fields: attachment_fields
  }]
end

#messageObject



33
34
35
# File 'app/models/integrations/chat_message/alert_message.rb', line 33

def message
  "Alert firing in #{strip_markup(project_name)}"
end