summaryrefslogtreecommitdiff
path: root/app/models/project_services/microsoft_teams_service.rb
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2017-04-04 16:10:21 +0100
committerTiago Botelho <tiagonbotelho@hotmail.com>2017-04-06 19:47:07 +0100
commit1f404065ca602593dc18aa051515fd88132ddfdf (patch)
treee1fb01a2584c2137ad603500fc22652ab099bb46 /app/models/project_services/microsoft_teams_service.rb
parent05f69ef21246f1a2c0b83540d3e205c9e4d77819 (diff)
downloadgitlab-ce-1f404065ca602593dc18aa051515fd88132ddfdf.tar.gz
adds relevant tests
Diffstat (limited to 'app/models/project_services/microsoft_teams_service.rb')
-rw-r--r--app/models/project_services/microsoft_teams_service.rb35
1 files changed, 12 insertions, 23 deletions
diff --git a/app/models/project_services/microsoft_teams_service.rb b/app/models/project_services/microsoft_teams_service.rb
index 2a8ea3f7e21..9b218fd81b4 100644
--- a/app/models/project_services/microsoft_teams_service.rb
+++ b/app/models/project_services/microsoft_teams_service.rb
@@ -4,14 +4,13 @@ class MicrosoftTeamsService < ChatNotificationService
end
def description
- 'Receive event notifications in Microsoft Team'
+ 'Receive event notifications in Microsoft Teams'
end
def self.to_param
'microsoft_teams'
end
- #TODO: Setup the description accordingly
def help
'This service sends notifications about projects events to Microsoft Teams channels.<br />
To set up this service:
@@ -22,10 +21,6 @@ class MicrosoftTeamsService < ChatNotificationService
</ol>'
end
- def default_channel_placeholder
- "Channel name (e.g. general)"
- end
-
def webhook_placeholder
'https://outlook.office.com/webhook/…'
end
@@ -33,6 +28,9 @@ class MicrosoftTeamsService < ChatNotificationService
def event_field(event)
end
+ def default_channel_placeholder
+ end
+
def default_fields
[
{ type: 'text', name: 'webhook', placeholder: "e.g. #{webhook_placeholder}" },
@@ -41,27 +39,18 @@ class MicrosoftTeamsService < ChatNotificationService
]
end
- def execute(data)
- return unless supported_events.include?(data[:object_kind])
- return unless webhook.present?
-
- object_kind = data[:object_kind]
+ private
- data = data.merge(
- project_url: project_url,
- project_name: project_name,
- markdown_format: true
- )
-
- message = get_message(object_kind, data)
-
- return false unless message
-
- MicrosoftTeams::Notifier.new(webhook).ping({
+ def notify(message, opts)
+ MicrosoftTeams::Notifier.new(webhook).ping(
title: message.project_name,
pretext: message.pretext,
activity: message.activity,
attachments: message.attachments
- })
+ )
+ end
+
+ def custom_data(data)
+ super(data).merge(markdown: true)
end
end