OSDN Git Service

notify commit author of new notes
authorJakub Zienkiewicz <jakub@zienkiewi.cz>
Fri, 13 Sep 2013 13:38:37 +0000 (15:38 +0200)
committerJakub Zienkiewicz <jakub@zienkiewi.cz>
Fri, 13 Sep 2013 13:38:37 +0000 (15:38 +0200)
app/services/notification_service.rb

index 71c25dc..750a71a 100644 (file)
@@ -107,12 +107,6 @@ class NotificationService
 
     opts = { noteable_type: note.noteable_type, project_id: note.project_id }
 
-    if note.commit_id.present?
-      opts.merge!(commit_id: note.commit_id)
-    else
-      opts.merge!(noteable_id: note.noteable_id)
-    end
-
     target = note.noteable
     if target.respond_to?(:participants)
       recipients = target.participants
@@ -120,6 +114,13 @@ class NotificationService
       recipients = note.mentioned_users
     end
 
+    if note.commit_id.present?
+      opts.merge!(commit_id: note.commit_id)
+      recipients << note.commit_author
+    else
+      opts.merge!(noteable_id: note.noteable_id)
+    end
+
     # Get users who left comment in thread
     recipients = recipients.concat(User.where(id: Note.where(opts).pluck(:author_id)))