summaryrefslogtreecommitdiff
path: root/app/models/project_services
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-08 15:09:29 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-08 15:09:29 +0000
commit5372e109c0660e4670aa987568a51082beca1b3c (patch)
tree76f8f1178d5f304f0aea8c0c610729f695c9e18e /app/models/project_services
parent403678e00406edc8094f087ec70e00aa29e49bef (diff)
downloadgitlab-ce-5372e109c0660e4670aa987568a51082beca1b3c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/project_services')
-rw-r--r--app/models/project_services/chat_notification_service.rb5
-rw-r--r--app/models/project_services/prometheus_service.rb8
2 files changed, 11 insertions, 2 deletions
diff --git a/app/models/project_services/chat_notification_service.rb b/app/models/project_services/chat_notification_service.rb
index 7bd011101dd..1ec983223f3 100644
--- a/app/models/project_services/chat_notification_service.rb
+++ b/app/models/project_services/chat_notification_service.rb
@@ -84,10 +84,11 @@ class ChatNotificationService < Service
event_type = data[:event_type] || object_kind
- channel_names = get_channel_field(event_type).presence || channel
+ channel_names = get_channel_field(event_type).presence || channel.presence
+ channels = channel_names&.split(',')&.map(&:strip)
opts = {}
- opts[:channel] = channel_names.split(',').map(&:strip) if channel_names
+ opts[:channel] = channels if channels.present?
opts[:username] = username if username
return false unless notify(message, opts)
diff --git a/app/models/project_services/prometheus_service.rb b/app/models/project_services/prometheus_service.rb
index 17bc29ebdcf..30dfcc11417 100644
--- a/app/models/project_services/prometheus_service.rb
+++ b/app/models/project_services/prometheus_service.rb
@@ -24,6 +24,8 @@ class PrometheusService < MonitoringService
after_commit :track_events
+ after_create_commit :create_default_alerts
+
def initialize_properties
if properties.nil?
self.properties = {}
@@ -147,4 +149,10 @@ class PrometheusService < MonitoringService
def disabled_manual_prometheus?
manual_configuration_changed? && !manual_configuration?
end
+
+ def create_default_alerts
+ return unless project_id
+
+ Prometheus::CreateDefaultAlertsWorker.perform_async(project_id: project_id)
+ end
end