From 003e4fdac0852446da83dfb2e1a23aa3ca5343cb Mon Sep 17 00:00:00 2001 From: PreciousPlum <40117915+preciousplum@users.noreply.github.com> Date: Sat, 23 Jun 2018 15:20:06 +0900 Subject: [PATCH] The problem of reminder mail functionality when users are specified was fixed. Mails are sent to the specified users only correctly now. --- init.rb | 2 +- lib/custom_users_as_assignees/mailer_patch.rb | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/init.rb b/init.rb index f6c1615..94970a5 100644 --- a/init.rb +++ b/init.rb @@ -27,7 +27,7 @@ name 'Expand Custom Users as Assignees plugin' author 'preciousplum' description 'Redmine plugin for adding assignee functionality includes default query and reminder to custom users' - version '0.0.2' + version '0.0.3' url 'https://github.com/preciousplum/custom_users_as_assignees' author_url 'https://github.com/preciousplum/' end diff --git a/lib/custom_users_as_assignees/mailer_patch.rb b/lib/custom_users_as_assignees/mailer_patch.rb index dd444de..034bf66 100644 --- a/lib/custom_users_as_assignees/mailer_patch.rb +++ b/lib/custom_users_as_assignees/mailer_patch.rb @@ -26,7 +26,6 @@ def reminders_with_custom_users(options={}) " AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" + " AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date ) - scope = scope.where(:assigned_to_id => user_ids) if user_ids.present? scope = scope.where(:project_id => project.id) if project scope = scope.where(:fixed_version_id => target_version_id) if target_version_id.present? scope = scope.where(:tracker_id => tracker.id) if tracker @@ -61,8 +60,10 @@ def reminders_with_custom_users(options={}) issues_by_assignee.each do |assignee, issues| if assignee.is_a?(User) && assignee.active? && issues.present? - visible_issues = issues.select {|i| i.visible?(assignee)} - reminder(assignee, visible_issues, days).deliver if visible_issues.present? + if user_ids.empty? || user_ids.include?(assignee.id.to_s) + visible_issues = issues.select {|i| i.visible?(assignee)} + reminder(assignee, visible_issues, days).deliver if visible_issues.present? + end end end end