Class: Integrations::ChatMessage::BaseMessage
- Inherits:
-
Object
- Object
- Integrations::ChatMessage::BaseMessage
- Defined in:
- app/models/integrations/chat_message/base_message.rb
Direct Known Subclasses
AlertMessage, DeploymentMessage, GroupMentionMessage, IssueMessage, MergeMessage, NoteMessage, PipelineMessage, PushMessage, WikiPageMessage
Constant Summary collapse
- RELATIVE_LINK_REGEX =
Gitlab::UntrustedRegexp.new('!\[[^\]]*\]\((/uploads/[^\)]*)\)')
Instance Attribute Summary collapse
-
#markdown ⇒ Object
readonly
Returns the value of attribute markdown.
-
#project_name ⇒ Object
readonly
Returns the value of attribute project_name.
-
#project_url ⇒ Object
readonly
Returns the value of attribute project_url.
-
#user_avatar ⇒ Object
readonly
Returns the value of attribute user_avatar.
-
#user_full_name ⇒ Object
readonly
Returns the value of attribute user_full_name.
-
#user_name ⇒ Object
readonly
Returns the value of attribute user_name.
Instance Method Summary collapse
-
#activity ⇒ Object
NOTE: Make sure to call ‘#strip_markup` on any untrusted user input that’s added to the ‘title`, `subtitle`, `text`, `fallback`, or `author_name` fields.
-
#attachments ⇒ Object
NOTE: Make sure to call ‘#strip_markup` on any untrusted user input that’s added to the ‘title`, `subtitle`, `text`, `fallback`, or `author_name` fields.
- #fallback ⇒ Object
-
#initialize(params) ⇒ BaseMessage
constructor
A new instance of BaseMessage.
- #pretext ⇒ Object
- #summary ⇒ Object
- #user_combined_name ⇒ Object
Constructor Details
#initialize(params) ⇒ BaseMessage
Returns a new instance of BaseMessage.
15 16 17 18 19 20 21 22 |
# File 'app/models/integrations/chat_message/base_message.rb', line 15 def initialize(params) @markdown = params[:markdown] || false @project_name = params[:project_name] || params.dig(:project, :path_with_namespace) @project_url = params.dig(:project, :web_url) || params[:project_url] @user_full_name = params.dig(:user, :name) || params[:user_full_name] @user_name = params.dig(:user, :username) || params[:user_name] @user_avatar = params.dig(:user, :avatar_url) || params[:user_avatar] end |
Instance Attribute Details
#markdown ⇒ Object (readonly)
Returns the value of attribute markdown.
8 9 10 |
# File 'app/models/integrations/chat_message/base_message.rb', line 8 def markdown @markdown end |
#project_name ⇒ Object (readonly)
Returns the value of attribute project_name.
12 13 14 |
# File 'app/models/integrations/chat_message/base_message.rb', line 12 def project_name @project_name end |
#project_url ⇒ Object (readonly)
Returns the value of attribute project_url.
13 14 15 |
# File 'app/models/integrations/chat_message/base_message.rb', line 13 def project_url @project_url end |
#user_avatar ⇒ Object (readonly)
Returns the value of attribute user_avatar.
11 12 13 |
# File 'app/models/integrations/chat_message/base_message.rb', line 11 def user_avatar @user_avatar end |
#user_full_name ⇒ Object (readonly)
Returns the value of attribute user_full_name.
9 10 11 |
# File 'app/models/integrations/chat_message/base_message.rb', line 9 def user_full_name @user_full_name end |
#user_name ⇒ Object (readonly)
Returns the value of attribute user_name.
10 11 12 |
# File 'app/models/integrations/chat_message/base_message.rb', line 10 def user_name @user_name end |
Instance Method Details
#activity ⇒ Object
NOTE: Make sure to call ‘#strip_markup` on any untrusted user input that’s added to the ‘title`, `subtitle`, `text`, `fallback`, or `author_name` fields.
54 55 56 |
# File 'app/models/integrations/chat_message/base_message.rb', line 54 def activity raise NotImplementedError end |
#attachments ⇒ Object
NOTE: Make sure to call ‘#strip_markup` on any untrusted user input that’s added to the ‘title`, `subtitle`, `text`, `fallback`, or `author_name` fields.
48 49 50 |
# File 'app/models/integrations/chat_message/base_message.rb', line 48 def raise NotImplementedError end |
#fallback ⇒ Object
42 43 44 |
# File 'app/models/integrations/chat_message/base_message.rb', line 42 def fallback format() end |
#pretext ⇒ Object
38 39 40 |
# File 'app/models/integrations/chat_message/base_message.rb', line 38 def pretext summary end |
#summary ⇒ Object
32 33 34 35 36 |
# File 'app/models/integrations/chat_message/base_message.rb', line 32 def summary return if markdown format() end |
#user_combined_name ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/models/integrations/chat_message/base_message.rb', line 24 def user_combined_name if user_full_name.present? "#{user_full_name} (#{user_name})" else user_name end end |