From a80f9b8927c7b71d02ee9728f95392612f99d8b0 Mon Sep 17 00:00:00 2001 From: Hunt Redmine Date: Thu, 5 Dec 2024 18:38:17 +0800 Subject: [PATCH 1/2] Emails are not sent to the author if no_self_notified --- app/models/dmsf_mailer.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/models/dmsf_mailer.rb b/app/models/dmsf_mailer.rb index 1abf8883..83cb4d41 100644 --- a/app/models/dmsf_mailer.rb +++ b/app/models/dmsf_mailer.rb @@ -158,9 +158,19 @@ def workflow_notification(user, workflow, revision, subject_id, text1_id, text2_ @notice = notice @author = revision.dmsf_workflow_assigned_by_user @author ||= User.anonymous - mail to: user, - subject: - "[#{@project.name} - #{l(:field_label_dmsf_workflow)}] #{@workflow.name} #{l(subject_id)} #{step_name}" + skip_no_self_notified = false + begin + # We need to switch off no_self_notified temporarily otherwise the email won't be sent + if (@author == user) && @author.pref.no_self_notified + @author.pref.no_self_notified = false + skip_no_self_notified = true + end + mail to: user, + subject: + "[#{@project.name} - #{l(:field_label_dmsf_workflow)}] #{@workflow.name} #{l(subject_id)} #{step_name}" + ensure + @author.pref.no_self_notified = true if skip_no_self_notified + end end # force_notification = true => approval workflow's notifications From 0ca3304a32dd58166c3026a122968d741317e3ec Mon Sep 17 00:00:00 2001 From: Hunt Redmine Date: Fri, 6 Dec 2024 15:12:04 +0800 Subject: [PATCH 2/2] Align the keys of a hash literal if they span more than one line. --- app/models/dmsf_mailer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/dmsf_mailer.rb b/app/models/dmsf_mailer.rb index 83cb4d41..252559f4 100644 --- a/app/models/dmsf_mailer.rb +++ b/app/models/dmsf_mailer.rb @@ -166,7 +166,7 @@ def workflow_notification(user, workflow, revision, subject_id, text1_id, text2_ skip_no_self_notified = true end mail to: user, - subject: + subject: "[#{@project.name} - #{l(:field_label_dmsf_workflow)}] #{@workflow.name} #{l(subject_id)} #{step_name}" ensure @author.pref.no_self_notified = true if skip_no_self_notified