Class: Integrations::ChatMessage::NoteMessage

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

Returns a new instance of NoteMessage.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/integrations/chat_message/note_message.rb', line 11

def initialize(params)
  super

  params = HashWithIndifferentAccess.new(params)
  obj_attr = params[:object_attributes]
  @note = obj_attr[:note]
  @note_url = obj_attr[:url]
  @target, @title = case obj_attr[:noteable_type]
                    when "Commit"
                      create_commit_note(params[:commit])
                    when "Issue"
                      create_issue_note(params[:issue])
                    when "MergeRequest"
                      create_merge_note(params[:merge_request])
                    when "Snippet"
                      create_snippet_note(params[:snippet])
                    end
end

Instance Attribute Details

#noteObject (readonly)

Returns the value of attribute note.



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

def note
  @note
end

#note_urlObject (readonly)

Returns the value of attribute note_url.



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

def note_url
  @note_url
end

#targetObject (readonly)

Returns the value of attribute target.



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

def target
  @target
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#activityObject



36
37
38
39
40
41
42
43
# File 'app/models/integrations/chat_message/note_message.rb', line 36

def activity
  {
    title: "#{strip_markup(user_combined_name)} #{link('commented on ' + target, note_url)}",
    subtitle: "in #{project_link}",
    text: strip_markup(formatted_title),
    image: user_avatar
  }
end

#attachmentsObject



30
31
32
33
34
# File 'app/models/integrations/chat_message/note_message.rb', line 30

def attachments
  return note if markdown

  description_message
end