From e833363e76a5bd8e557522f719023e3963a05f2a Mon Sep 17 00:00:00 2001 From: Juno NISHIZAKI Date: Thu, 27 Jan 2022 10:03:13 +0900 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC16=E5=9B=9E=E4=BD=9C=E6=A5=AD=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 15 +++++++++------ app/views/layouts/mailer.html.erb | 11 +++++++++++ app/views/layouts/mailer.text.erb | 5 +++++ app/views/settings/_notifications.html.erb | 4 ++++ config/locales/en.yml | 3 +++ config/locales/ja.yml | 3 +++ config/settings.yml | 5 +++++ 7 files changed, 40 insertions(+), 6 deletions(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 3007350b71..38c61af5a0 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -70,7 +70,7 @@ def self.default_url_options end # Builds a mail for notifying user about a new issue - def issue_add(user, issue) + def issue_add(user, issue, recipients) redmine_headers 'Project' => issue.project.identifier, 'Issue-Tracker' => issue.tracker.name, 'Issue-Id' => issue.id, @@ -81,6 +81,7 @@ def issue_add(user, issue) @author = issue.author @issue = issue @user = user + @recipients = recipients @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue) subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]" subject += " (#{issue.status.name})" if Setting.show_status_changes_in_mail_subject? @@ -96,12 +97,12 @@ def issue_add(user, issue) def self.deliver_issue_add(issue) users = issue.notified_users | issue.notified_watchers | issue.notified_mentions users.each do |user| - issue_add(user, issue).deliver_later + issue_add(user, issue, users).deliver_later end end # Builds a mail for notifying user about an issue update - def issue_edit(user, journal) + def issue_edit(user, journal, recipients) issue = journal.journalized redmine_headers 'Project' => issue.project.identifier, 'Issue-Tracker' => issue.tracker.name, @@ -116,6 +117,7 @@ def issue_edit(user, journal) s += issue.subject @issue = issue @user = user + @recipients = recipients @journal = journal @journal_details = journal.visible_details @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}") @@ -134,16 +136,17 @@ def self.deliver_issue_edit(journal) journal.notes? || journal.visible_details(user).any? end users.each do |user| - issue_edit(user, journal).deliver_later + issue_edit(user, journal, users).deliver_later end end # Builds a mail to user about a new document. - def document_added(user, document, author) + def document_added(user, document, author, recipients) redmine_headers 'Project' => document.project.identifier @author = author @document = document @user = user + @recipients = recipients @document_url = url_for(:controller => 'documents', :action => 'show', :id => document) mail :to => user, :subject => "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}" @@ -156,7 +159,7 @@ def document_added(user, document, author) def self.deliver_document_added(document, author) users = document.notified_users users.each do |user| - document_added(user, document, author).deliver_later + document_added(user, document, author, users).deliver_later end end diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb index fff36c0cbc..ffa10aa76a 100644 --- a/app/views/layouts/mailer.html.erb +++ b/app/views/layouts/mailer.html.erb @@ -25,6 +25,11 @@ span.footer { font-size: 0.8em; font-style: italic; } +span.recipients { + font-size: 0.8em; + font-style: italic; + color: #959595; +} blockquote { font-style: italic; border-left: 3px solid #e0e0e0; padding-left: 0.6em; margin-left: 0;} blockquote blockquote { margin-left: 0;} pre, code {font-family: Consolas, Menlo, "Liberation Mono", Courier, monospace;} @@ -78,5 +83,11 @@ table, td, th { <% if Setting.emails_footer.present? -%> <%= Redmine::WikiFormatting.to_html(Setting.text_formatting, Setting.emails_footer).html_safe %> <% end -%> +<% if Setting.show_recipients_in_mail_footer? && @recipients.present? %> + + <%= l(:text_sent_email_to_recipients) %>
+ <%= @recipients.take(Setting.show_recipients_limit.to_i).map(&:name).join(', ') %><%= '...' if @recipients.size > Setting.show_recipients_limit.to_i %> +
+<% end %> diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb index a4c69862b8..b18996ad96 100644 --- a/app/views/layouts/mailer.text.erb +++ b/app/views/layouts/mailer.text.erb @@ -6,3 +6,8 @@ -- <%= Setting.emails_footer %> <% end -%> +<% if Setting.show_recipients_in_mail_footer? && @recipients.present? %> + +<%= l(:text_sent_email_to_recipients) %> +<%= @recipients.take(Setting.show_recipients_limit.to_i).map(&:name).join(', ') %><%= '...' if @recipients.size > Setting.show_recipients_limit.to_i %> +<% end -%> \ No newline at end of file diff --git a/app/views/settings/_notifications.html.erb b/app/views/settings/_notifications.html.erb index aafbe43403..15812d91ae 100644 --- a/app/views/settings/_notifications.html.erb +++ b/app/views/settings/_notifications.html.erb @@ -7,6 +7,10 @@

<%= setting_check_box :plain_text_mail %>

<%= setting_check_box :show_status_changes_in_mail_subject %>

+ +

<%= setting_check_box :show_recipients_in_mail_footer, :data => {:enables => '#settings_show_recipients_limit'} %>

+ +

<%= setting_text_field :show_recipients_limit, :size => 6%>

<%=l(:text_select_mail_notifications)%> diff --git a/config/locales/en.yml b/config/locales/en.yml index 62577376fa..82b7fe1ced 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -506,6 +506,8 @@ en: setting_timelog_max_hours_per_day: Maximum hours that can be logged per day and user setting_timelog_accept_future_dates: Accept time logs on future dates setting_show_status_changes_in_mail_subject: Show status changes in issue mail notifications subject + setting_show_recipients_in_mail_footer: Show recipients in mail notifications footer + setting_show_recipients_limit: Maximum number of recipients in mail notifications footer setting_project_list_defaults: Projects list defaults setting_twofa: Two-factor authentication @@ -1232,6 +1234,7 @@ en: text_issues_ref_in_commit_messages: Referencing and fixing issues in commit messages text_issue_added: "Issue %{id} has been reported by %{author}." text_issue_updated: "Issue %{id} has been updated by %{author}." + text_sent_email_to_recipients: The following recipients have also received this email. text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content? text_issue_category_destroy_question: "Some issues (%{count}) are assigned to this category. What do you want to do?" text_issue_category_destroy_assignments: Remove category assignments diff --git a/config/locales/ja.yml b/config/locales/ja.yml index f0435e5239..cb4a930141 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -903,6 +903,7 @@ ja: text_issues_ref_in_commit_messages: コミットメッセージ内でチケットの参照/修正 text_issue_added: "チケット %{id} を %{author} さんが作成しました。" text_issue_updated: "チケット %{id} を %{author} さんが更新しました。" + text_sent_email_to_recipients: 次のユーザーにもこのメールを送信しました。 text_wiki_destroy_confirmation: 本当にこのwikiとその内容のすべてを削除しますか? text_issue_category_destroy_question: "%{count}件のチケットがこのカテゴリに割り当てられています。" text_issue_category_destroy_assignments: カテゴリの割り当てを削除する @@ -1265,6 +1266,8 @@ ja: text_status_no_workflow: このステータスはどのトラッカーのワークフローでも使われていません setting_mail_handler_preferred_body_part: マルチパート (HTML) メールの優先パート setting_show_status_changes_in_mail_subject: 通知メールの題名にステータス変更の情報を挿入 + setting_show_recipients_in_mail_footer: 通知メールのフッタに受信者の情報を挿入 + setting_show_recipients_limit: 通知メールのフッタに挿入される受信者数の上限 label_inherited_from_parent_project: 親プロジェクトから継承 label_inherited_from_group: グループ %{name} から継承 label_trackers_description: トラッカーの説明 diff --git a/config/settings.yml b/config/settings.yml index 0c41b7eda1..20ecf32512 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -341,3 +341,8 @@ timelog_accept_future_dates: default: 1 show_status_changes_in_mail_subject: default: 1 +show_recipients_in_mail_footer: + default: 0 +show_recipients_limit: + format: int + default: 15 \ No newline at end of file