Class: Integrations::GroupMentionService
- Inherits:
-
Object
- Object
- Integrations::GroupMentionService
- Defined in:
- app/services/integrations/group_mention_service.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(mentionable, hook_data:, is_confidential:) ⇒ GroupMentionService
constructor
A new instance of GroupMentionService.
Constructor Details
#initialize(mentionable, hook_data:, is_confidential:) ⇒ GroupMentionService
Returns a new instance of GroupMentionService.
12 13 14 15 16 |
# File 'app/services/integrations/group_mention_service.rb', line 12 def initialize(mentionable, hook_data:, is_confidential:) @mentionable = mentionable @hook_data = hook_data @is_confidential = is_confidential end |
Instance Method Details
#execute ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/services/integrations/group_mention_service.rb', line 18 def execute return ServiceResponse.success if mentionable.nil? || hook_data.nil? @hook_data = hook_data.clone # Fake a "group_mention" object kind so integrations can handle this as a separate class of event hook_data[:object_attributes][:object_kind] = hook_data[:object_kind] hook_data[:object_kind] = 'group_mention' if confidential? hook_data[:event_type] = 'group_confidential_mention' hook_scope = :group_confidential_mention_hooks else hook_data[:event_type] = 'group_mention' hook_scope = :group_mention_hooks end groups = mentionable.referenced_groups(mentionable.) groups.each do |group| group_hook_data = hook_data.merge( mentioned: { object_kind: 'group', name: group.full_path, url: group.web_url } ) group.execute_integrations(group_hook_data, hook_scope) end ServiceResponse.success end |