diff options
Diffstat (limited to 'app/models/project_services/chat_notification_service.rb')
-rw-r--r-- | app/models/project_services/chat_notification_service.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/app/models/project_services/chat_notification_service.rb b/app/models/project_services/chat_notification_service.rb index 1d50d5cf19e..cf7cad09676 100644 --- a/app/models/project_services/chat_notification_service.rb +++ b/app/models/project_services/chat_notification_service.rb @@ -97,9 +97,12 @@ class ChatNotificationService < Service opts[:channel] = channels if channels.present? opts[:username] = username if username - return false unless notify(message, opts) + if notify(message, opts) + log_usage(event_type, user_id_from_hook_data(data)) + return true + end - true + false end def event_channel_names @@ -120,6 +123,10 @@ class ChatNotificationService < Service private + def log_usage(_, _) + # Implement in child class + end + def labels_to_be_notified_list return [] if labels_to_be_notified.nil? @@ -136,6 +143,10 @@ class ChatNotificationService < Service (labels_to_be_notified_list & label_titles).any? end + def user_id_from_hook_data(data) + data.dig(:user, :id) || data[:user_id] + end + # every notifier must implement this independently def notify(message, opts) raise NotImplementedError |