From 0279d9240ff9c12924452965a7f3abb3bca05f4c Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 4 Jul 2013 12:56:35 +0400 Subject: [PATCH] #200: send only one message on create --- lib/modules/observers/activity_feed/issue.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/modules/observers/activity_feed/issue.rb b/lib/modules/observers/activity_feed/issue.rb index a098190fa..d2f9736be 100644 --- a/lib/modules/observers/activity_feed/issue.rb +++ b/lib/modules/observers/activity_feed/issue.rb @@ -3,8 +3,9 @@ module Modules::Observers::ActivityFeed::Issue extend ActiveSupport::Concern included do - after_commit :new_issue_notifications, :on => :create - after_update -> { send_assign_notifications(:update) } + after_commit :new_issue_notifications, :on => :create + after_commit :send_assign_notifications, :on => :create + after_commit -> { send_assign_notifications(:update) }, :on => :update end private @@ -12,7 +13,9 @@ module Modules::Observers::ActivityFeed::Issue def new_issue_notifications collect_recipients.each do |recipient| next if user_id == recipient.id - UserMailer.new_issue_notification(self, recipient).deliver if recipient.notifier.can_notify && recipient.notifier.new_issue + if recipient.notifier.can_notify && recipient.notifier.new_issue && assignee_id != recipient.id + UserMailer.new_issue_notification(self, recipient).deliver + end ActivityFeed.create( :user => recipient, :kind => 'new_issue_notification', @@ -28,7 +31,6 @@ module Modules::Observers::ActivityFeed::Issue } ) end - send_assign_notifications end def send_assign_notifications(action = :create)