From b7cc64c09929d1640ac61fe6c21adf69f3e7394e Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 28 Aug 2013 19:13:11 +0400 Subject: [PATCH 1/3] #283: Email notifications and ActivityFeed for publisher --- app/models/build_list.rb | 20 +++++++++---------- .../observers/activity_feed/build_list.rb | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 603e1bba8..07a2b57b0 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -448,17 +448,15 @@ class BuildList < ActiveRecord::Base def notify_users unless mass_build_id - users = [] - if project # find associated users - users = project.all_members. - select{ |user| user.notifier.can_notify? && user.notifier.new_associated_build? } - end - if user.notifier.can_notify? && user.notifier.new_build? - users = users | [user] - end - users.each do |user| - UserMailer.build_list_notification(self, user).deliver - end + users = [user] + users << publisher if publisher + users.select!{ |u| u.notifier.can_notify? && u.notifier.new_build? } + + # find associated users + users |= project.all_members.select do |u| + u.notifier.can_notify? && u.notifier.new_associated_build? + end if project + users.each{ |u| UserMailer.build_list_notification(self, u).deliver } end end # notify_users diff --git a/lib/modules/observers/activity_feed/build_list.rb b/lib/modules/observers/activity_feed/build_list.rb index e78719ca7..5a4d764cb 100644 --- a/lib/modules/observers/activity_feed/build_list.rb +++ b/lib/modules/observers/activity_feed/build_list.rb @@ -21,7 +21,7 @@ module Modules::Observers::ActivityFeed::BuildList ) updater = publisher || user - project.admins.each do |recipient| + (project.admins | [publisher].compact).each do |recipient| ActivityFeed.create( :user => recipient, :kind => 'build_list_notification', From b17641e575ca607c6825b3a12d649ff6e2ef0c80 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 28 Aug 2013 19:17:22 +0400 Subject: [PATCH 2/3] #283: added extra condition to #notify_users --- app/models/build_list.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 07a2b57b0..0e4e3debe 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -449,7 +449,7 @@ class BuildList < ActiveRecord::Base def notify_users unless mass_build_id users = [user] - users << publisher if publisher + users << publisher if publisher && user_id != publisher_id users.select!{ |u| u.notifier.can_notify? && u.notifier.new_build? } # find associated users From a32d6193464fe82ea650f1c6827c9f4897026e2a Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Wed, 28 Aug 2013 19:20:18 +0400 Subject: [PATCH 3/3] #283: small refactoring --- app/models/build_list.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 0e4e3debe..7ddb2a00c 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -448,10 +448,8 @@ class BuildList < ActiveRecord::Base def notify_users unless mass_build_id - users = [user] - users << publisher if publisher && user_id != publisher_id - users.select!{ |u| u.notifier.can_notify? && u.notifier.new_build? } - + users = [user, publisher].compact.uniq.select{ |u| u.notifier.can_notify? && u.notifier.new_build? } + # find associated users users |= project.all_members.select do |u| u.notifier.can_notify? && u.notifier.new_associated_build?