From 9bd4890c3224e6570718bed00ace1c9625995c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Wed, 28 Jan 2015 13:30:13 +0100 Subject: [PATCH] Unwanted notifications #340 --- app/controllers/dmsf_upload_controller.rb | 26 ++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/app/controllers/dmsf_upload_controller.rb b/app/controllers/dmsf_upload_controller.rb index 741a95bf..cd3d845b 100644 --- a/app/controllers/dmsf_upload_controller.rb +++ b/app/controllers/dmsf_upload_controller.rb @@ -177,20 +177,22 @@ class DmsfUploadController < ApplicationController end unless files.empty? files.each { |file| log_activity(file, 'uploaded') if file } - begin - recipients = DmsfMailer.get_notify_users(@project, files) - recipients.each do |u| - DmsfMailer.files_updated(u, @project, files).deliver - end - if Setting.plugin_redmine_dmsf[:dmsf_display_notified_recipients] == '1' - unless recipients.empty? - to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ') - to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.') - flash[:warning] = l(:warning_email_notifications, :to => to) + if (@folder && @folder.notification?) || (!@folder && @project.dmsf_notification?) + begin + recipients = DmsfMailer.get_notify_users(@project, files) + recipients.each do |u| + DmsfMailer.files_updated(u, @project, files).deliver + end + if Setting.plugin_redmine_dmsf[:dmsf_display_notified_recipients] == '1' + unless recipients.empty? + to = recipients.collect{ |r| r.name }.first(DMSF_MAX_NOTIFICATION_RECEIVERS_INFO).join(', ') + to << ((recipients.count > DMSF_MAX_NOTIFICATION_RECEIVERS_INFO) ? ',...' : '.') + flash[:warning] = l(:warning_email_notifications, :to => to) + end end + rescue Exception => e + Rails.logger.error "Could not send email notifications: #{e.message}" end - rescue Exception => e - Rails.logger.error "Could not send email notifications: #{e.message}" end end unless failed_uploads.empty?