Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add content for mentioned mail

Henriette Dargedfbd0f8ef042
diff --git a/app/helpers/mail_digest_helper.rb b/app/helpers/mail_digest_helper.rb
index 70900cf54bd..5dd649a6c02 100644
--- a/app/helpers/mail_digest_helper.rb
+++ b/app/helpers/mail_digest_helper.rb
@@ -53,9 +53,9 @@ module MailDigestHelper
def digest_comment_text(notification)
if notification.reason_mail_digest === "mentioned"
- sanitize I18n.t(:'mail.digests.work_packages.mentioned')
+ sanitize I18n.t(:'mail.work_packages.mentioned')
else
- sanitize I18n.t(:'mail.digests.work_packages.comment_added')
+ sanitize I18n.t(:'mail.work_packages.comment_added')
end
end
@@ -65,14 +65,14 @@ module MailDigestHelper
value = journal.initial? ? "created" : "updated"
if extended
sanitize(
- "#{I18n.t(:"mail.digests.work_packages.#{value}")} #{I18n.t(:"mail.digests.work_packages.#{value}_at",
+ "#{I18n.t(:"mail.work_packages.#{value}")} #{I18n.t(:"mail.work_packages.#{value}_at",
user: user,
timestamp: journal.created_at.strftime(
I18n.t(:'time.formats.time')
))}"
)
else
- sanitize(I18n.t(:"mail.digests.work_packages.#{value}_at",
+ sanitize(I18n.t(:"mail.work_packages.#{value}_at",
user: user,
timestamp: journal.created_at.strftime(I18n.t(:'time.formats.time'))))
end
diff --git a/app/mailers/work_package_mailer.rb b/app/mailers/work_package_mailer.rb
index 255c74e68c6..dd4ea81c792 100644
--- a/app/mailers/work_package_mailer.rb
+++ b/app/mailers/work_package_mailer.rb
@@ -29,12 +29,17 @@
#++
class WorkPackageMailer < ApplicationMailer
+ helper :mail_notification
+
def mentioned(recipient, journal)
+ @user = recipient
+ @work_package = journal.journable
+ @journal = journal
+
author = journal.user
- work_package = journal.journable
User.execute_as author do
- set_work_package_headers(work_package)
+ set_work_package_headers(@work_package)
message_id journal, recipient
@@ -42,8 +47,8 @@ class WorkPackageMailer < ApplicationMailer
mail to: recipient.mail,
subject: I18n.t(:'mail.mention.subject',
user_name: author.name,
- id: work_package.id,
- subject: work_package.subject)
+ id: @work_package.id,
+ subject: @work_package.subject)
end
end
end
diff --git a/app/views/digest_mailer/work_packages.html.erb b/app/views/digest_mailer/work_packages.html.erb
index 925af8c248d..bfb74771bda 100644
--- a/app/views/digest_mailer/work_packages.html.erb
+++ b/app/views/digest_mailer/work_packages.html.erb
@@ -16,7 +16,9 @@
<%= render layout: 'mailer/notification_row',
locals: {
work_package: work_package,
- notifications_by_work_package: notifications_by_work_package
+ unique_reasons: unique_reasons_of_notifications(notifications_by_work_package),
+ show_count: true,
+ count: notifications_by_work_package.length
} do %>
<table <%= placeholder_table_styles %>>
<% notifications_by_work_package.each do | notification | %>
@@ -54,7 +56,7 @@
<span style="font-size:14px;">
<% number_of_overflowing_work_packages = @aggregated_notifications.length - DigestMailer::MAX_SHOWN_WORK_PACKAGES %>
<% count = number_of_overflowing_work_packages === 1 ? 'one' : 'other' %>
- <%= I18n.t(:"mail.digests.work_packages.more_to_see.#{count}", count: number_of_overflowing_work_packages) %>
+ <%= I18n.t(:"mail.work_packages.more_to_see.#{count}", count: number_of_overflowing_work_packages) %>
</span>
</td>
<%= placeholder_cell('10px', vertical: true) %>
@@ -69,7 +71,7 @@
text-decoration: none;
font-size:14px;
white-space: nowrap;">
- <%= I18n.t(:'mail.digests.work_packages.see_all') %>
+ <%= I18n.t(:'mail.work_packages.see_all') %>
</a>
</td>
</tr>
diff --git a/app/views/digest_mailer/work_packages.text.erb b/app/views/digest_mailer/work_packages.text.erb
index 860cbb0b672..7bd18a54828 100644
--- a/app/views/digest_mailer/work_packages.text.erb
+++ b/app/views/digest_mailer/work_packages.text.erb
@@ -15,7 +15,7 @@
<%= digest_notification_timestamp_text(
notification,
html: false,
- extended_text: true) %> (<% unique_reasons.each_with_index do |reason, index| %><%= I18n.t(:"mail.digests.work_packages.reason.#{reason || :unknown}", default: '-') %><%= ', ' unless unique_reasons.size-1 == index %><% end %>)
+ extended_text: true) %> (<% unique_reasons.each_with_index do |reason, index| %><%= I18n.t(:"mail.work_packages.reason.#{reason || :unknown}", default: '-') %><%= ', ' unless unique_reasons.size-1 == index %><% end %>)
<% journal = notification.journal %>
<% if journal.notes.present? %>
@@ -36,5 +36,5 @@
<% if @aggregated_notifications.length > DigestMailer::MAX_SHOWN_WORK_PACKAGES %>
<% number_of_overflowing_work_packages = @aggregated_notifications.length - DigestMailer::MAX_SHOWN_WORK_PACKAGES %>
<% count = number_of_overflowing_work_packages === 1 ? 'one' : 'other' %>
-<%= I18n.t(:"mail.digests.work_packages.more_to_see.#{count}", count: number_of_overflowing_work_packages) %>
+<%= I18n.t(:"mail.work_packages.more_to_see.#{count}", count: number_of_overflowing_work_packages) %>
<% end %>
diff --git a/app/views/mailer/_notification_row.html.erb b/app/views/mailer/_notification_row.html.erb
index 6850e2e3085..a11a1f4f427 100644
--- a/app/views/mailer/_notification_row.html.erb
+++ b/app/views/mailer/_notification_row.html.erb
@@ -30,26 +30,27 @@
<%= placeholder_cell('8px', vertical: true) %>
<td width="100%" style="color: #878787;">
#<%= work_package.id %> - <%= work_package.project %>
- <% unique_reasons = unique_reasons_of_notifications(notifications_by_work_package) %>
<%= ' - ' unless unique_reasons.length === 1 && unique_reasons.first.nil? %>
<% unique_reasons.each_with_index do |reason, index| %>
<%= I18n.t(
- :"mail.digests.work_packages.reason.#{reason || :unknown}",
+ :"mail.work_packages.reason.#{reason || :unknown}",
default: '') %><%= ', ' unless unique_reasons.size-1 == index %>
<% end %>
</td>
<td>
<table <%= placeholder_table_styles %>>
<tr>
- <td style="background-color: #00A3FF;
- color: white;
- border-radius: 10px;
- padding: 2px 8px;
- font-size: 14px;
- height: 18px;
- line-height: 18px;">
- <%= notifications_by_work_package.length %>
- </td>
+ <% if show_count %>
+ <td style="background-color: #00A3FF;
+ color: white;
+ border-radius: 10px;
+ padding: 2px 8px;
+ font-size: 14px;
+ height: 18px;
+ line-height: 18px;">
+ <%= count %>
+ </td>
+ <% end %>
</tr>
</table>
</td>
diff --git a/app/views/work_package_mailer/mentioned.html.erb b/app/views/work_package_mailer/mentioned.html.erb
index e69de29bb2d..147d9111cbd 100644
--- a/app/views/work_package_mailer/mentioned.html.erb
+++ b/app/views/work_package_mailer/mentioned.html.erb
@@ -0,0 +1,55 @@
+<table <%= placeholder_table_styles %>>
+ <tr>
+ <%= placeholder_cell('20px', vertical: false) %>
+ </tr>
+</table>
+
+<table <%= placeholder_table_styles(width:'100%',style: 'width:100%;max-width:700px;margin-left:auto;margin-right:auto') %>>
+ <tr>
+ <td>
+ <%= render partial: 'mailer/notification_mailer_header',
+ locals: {
+ summary: "#{I18n.t(:'mail.work_packages.mentioned_by', user: @journal.user)}"
+ } %>
+
+ <%= render layout: 'mailer/notification_row',
+ locals: {
+ work_package: @work_package,
+ unique_reasons: [I18n.t(:'mail.work_packages.reason.mentioned')],
+ show_count: false
+ } do %>
+ <table <%= placeholder_table_styles %>>
+ <tr>
+ <td style="color: #878787; line-height: 24px; font-size: 14px; white-space: normal;">
+ <%= @journal.notes.html_safe %>
+ </td>
+ </tr>
+ </table>
+ <% end %>
+
+ <table <%= placeholder_table_styles(style: 'font-size:14px;') %>>
+ <tr>
+ <td>
+ <table <%= placeholder_table_styles(width:'100%',style: 'width:100%;') %>>
+ <tr>
+ <td>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <%= placeholder_cell('10px', vertical: true) %>
+ <td>
+ <%= render partial: 'mailer/notification_settings_button' %>
+ </td>
+ </tr>
+ </table>
+
+ <table>
+ <tr>
+ <%= placeholder_cell('20px', vertical: false) %>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+
diff --git a/app/views/work_package_mailer/mentioned.text.erb b/app/views/work_package_mailer/mentioned.text.erb
index e69de29bb2d..795b94f9339 100644
--- a/app/views/work_package_mailer/mentioned.text.erb
+++ b/app/views/work_package_mailer/mentioned.text.erb
@@ -0,0 +1,13 @@
+<%= I18n.t(:'mail.salutation', user: @user.firstname) %>
+<%= "#{I18n.t(:'mail.work_packages.mentioned_by', user: @journal.user)}" %>
+<%= "-" * 100 %>
+
+
+<%= "=" * (('# ' + @work_package.id.to_s + @work_package.subject).length + 4) %>
+= #<%= @work_package.id %> <%= @work_package.subject %> =
+<%= "=" * (('# ' + @work_package.id.to_s + @work_package.subject).length + 4) %>
+
+<%= I18n.t(:label_comment_added) %>:
+<%= @journal.notes %>
+
+<%= "-" * 100 %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index fbba1f23a52..4351880f5f7 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1977,25 +1977,6 @@ en:
including_mention_plural: 'including %{number_mentioned} mentions'
unread_notification_singular: '1 unread notification'
unread_notification_plural: '%{number_unread} unread notifications'
- work_packages:
- comment_added: '<b>Comment</b> added'
- created: 'Created'
- created_at: 'at %{timestamp} by %{user} '
- login_to_see_all: 'Log in to see all notifications.'
- mentioned: 'You have been <b>mentioned in a comment</b>'
- more_to_see:
- one: 'There is 1 more work package with notifications.'
- other: 'There are %{count} more work packages with notifications.'
- reason:
- watched: 'Watched'
- assigned: 'Assigned'
- responsible: 'Accountable'
- mentioned: 'Mentioned'
- subscribed: 'all'
- prefix: 'Received because of the notification setting: %{reason}'
- see_all: 'See all'
- updated: 'Updated'
- updated_at: 'at %{timestamp} by %{user}'
you_have: 'You have'
logo_alt_text: 'Logo'
mention:
@@ -2004,6 +1985,26 @@ en:
center: 'To notification center'
settings: 'Change email settings'
salutation: 'Hey %{user}!'
+ work_packages:
+ comment_added: '<b>Comment</b> added'
+ created: 'Created'
+ created_at: 'at %{timestamp} by %{user} '
+ login_to_see_all: 'Log in to see all notifications.'
+ mentioned: 'You have been <b>mentioned in a comment</b>'
+ mentioned_by: '%{user} mentioned you in a comment'
+ more_to_see:
+ one: 'There is 1 more work package with notifications.'
+ other: 'There are %{count} more work packages with notifications.'
+ reason:
+ watched: 'Watched'
+ assigned: 'Assigned'
+ responsible: 'Accountable'
+ mentioned: 'Mentioned'
+ subscribed: 'all'
+ prefix: 'Received because of the notification setting: %{reason}'
+ see_all: 'See all'
+ updated: 'Updated'
+ updated_at: 'at %{timestamp} by %{user}'
mail_body_account_activation_request: "A new user (%{value}) has registered. The account is pending your approval:"
mail_body_account_information: "Your account information"