diff options
author | Stan Hu <stanhu@gmail.com> | 2015-02-19 05:02:57 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-03-03 11:14:31 +0100 |
commit | afe5d7d209a4088d71e35d6382e6523b89f94ebe (patch) | |
tree | a3432580bee64e1c9f30b0815426c31e3220d021 /app/services/merge_requests | |
parent | 2f4656b5c7e2a9b351237432e76a7b928a1684b1 (diff) | |
download | gitlab-ce-afe5d7d209a4088d71e35d6382e6523b89f94ebe.tar.gz |
Issue #595: Support Slack notifications upon issue and merge request events
1) Adds a DB migration for all services to toggle on push, issue, and merge events.
2) Upon an issue or merge request event, fire service hooks.
3) Slack service supports custom messages for each of these events. Other services
not supported at the moment.
4) Label merge request hooks with their corresponding actions.
Diffstat (limited to 'app/services/merge_requests')
-rw-r--r-- | app/services/merge_requests/base_service.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/app/services/merge_requests/base_service.rb b/app/services/merge_requests/base_service.rb index b4199d1c800..f6e1ae6f283 100644 --- a/app/services/merge_requests/base_service.rb +++ b/app/services/merge_requests/base_service.rb @@ -5,13 +5,19 @@ module MergeRequests Note.create_status_change_note(merge_request, merge_request.target_project, current_user, merge_request.state, nil) end + def hook_data(merge_request, action) + hook_data = merge_request.to_hook_data(current_user) + merge_request_url = Gitlab::UrlBuilder.new(:merge_request).build(merge_request.id) + hook_data[:object_attributes][:url] = merge_request_url + hook_data[:object_attributes][:action] = action + hook_data + end + def execute_hooks(merge_request, action = 'open') if merge_request.project - hook_data = merge_request.to_hook_data(current_user) - merge_request_url = Gitlab::UrlBuilder.new(:merge_request).build(merge_request.id) - hook_data[:object_attributes][:url] = merge_request_url - hook_data[:object_attributes][:action] = action - merge_request.project.execute_hooks(hook_data, :merge_request_hooks) + merge_data = hook_data(merge_request, action) + merge_request.project.execute_hooks(merge_data, :merge_request_hooks) + merge_request.project.execute_services(merge_data, :merge_request_hooks) end end end |