summaryrefslogtreecommitdiff
path: root/app/models/service.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2015-02-19 05:02:57 +0000
committerDouwe Maan <douwe@gitlab.com>2015-03-03 11:14:31 +0100
commitafe5d7d209a4088d71e35d6382e6523b89f94ebe (patch)
treea3432580bee64e1c9f30b0815426c31e3220d021 /app/models/service.rb
parent2f4656b5c7e2a9b351237432e76a7b928a1684b1 (diff)
downloadgitlab-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/models/service.rb')
-rw-r--r--app/models/service.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/service.rb b/app/models/service.rb
index f4e97da3212..9d6866f26d0 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -11,6 +11,11 @@
# active :boolean default(FALSE), not null
# properties :text
# template :boolean default(FALSE)
+# push_events :boolean
+# issues_events :boolean
+# merge_requests_events :boolean
+# tag_push_events :boolean
+#
# To add new service you should build a class inherited from Service
# and implement a set of methods
@@ -19,6 +24,10 @@ class Service < ActiveRecord::Base
serialize :properties, JSON
default_value_for :active, false
+ default_value_for :push_events, true
+ default_value_for :issues_events, true
+ default_value_for :merge_requests_events, true
+ default_value_for :tag_push_events, true
after_initialize :initialize_properties
@@ -29,6 +38,11 @@ class Service < ActiveRecord::Base
scope :visible, -> { where.not(type: 'GitlabIssueTrackerService') }
+ scope :push_hooks, -> { where(push_events: true, active: true) }
+ scope :tag_push_hooks, -> { where(tag_push_events: true, active: true) }
+ scope :issue_hooks, -> { where(issues_events: true, active: true) }
+ scope :merge_request_hooks, -> { where(merge_requests_events: true, active: true) }
+
def activated?
active
end