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

Show timestamp text instead of notification details in email

Henriette Dargee975a418ed57
diff --git a/app/helpers/mail_digest_helper.rb b/app/helpers/mail_digest_helper.rb
index 3b6afe1309e..e0886169cf2 100644
--- a/app/helpers/mail_digest_helper.rb
+++ b/app/helpers/mail_digest_helper.rb
@@ -44,37 +44,36 @@ module MailDigestHelper
summary
end
- def digest_notification_timestamp_text(notification, html: true, extended_text: false)
+ def digest_notification_timestamp_text(notification, html: true)
journal = notification.journal
user = html ? link_to_user(journal.user, only_path: false) : journal.user.name
- timestamp_text(user, journal, extended_text)
+ timestamp_text(user, journal)
end
- def digest_comment_text(notification)
- if notification.reason_mentioned?
- sanitize I18n.t(:'mail.work_packages.mentioned')
- else
- sanitize I18n.t(:'mail.work_packages.comment_added')
+ def digest_additional_author_text(notifications)
+ number_of_additional_authors = number_of_authors(notifications) - 1
+
+ if notifications.length > 1 && number_of_additional_authors > 0
+ amount = number_of_additional_authors === 1 ? 'one' : 'other'
+ I18n.t(:"js.notifications.center.and_more_users.#{amount}", count: number_of_additional_authors)
end
end
private
- def timestamp_text(user, journal, extended)
+ def timestamp_text(user, journal)
value = journal.initial? ? "created" : "updated"
- if extended
- sanitize(
- "#{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.work_packages.#{value}_at",
- user: user,
- timestamp: journal.created_at.strftime(I18n.t(:'time.formats.time'))))
- end
+ sanitize(
+ I18n.t(:"mail.work_packages.#{value}_at",
+ user: user,
+ timestamp: journal.created_at.strftime(
+ "#{I18n.t(:'date.formats.default')}, #{I18n.t(:'time.formats.time')}"
+ ))
+ )
+ end
+
+ def number_of_authors(notifications)
+ notifications.group_by { |n| n[:actor_id] }.count
end
end
diff --git a/app/views/digest_mailer/work_packages.html.erb b/app/views/digest_mailer/work_packages.html.erb
index 5983215a08b..58790884b66 100644
--- a/app/views/digest_mailer/work_packages.html.erb
+++ b/app/views/digest_mailer/work_packages.html.erb
@@ -28,24 +28,12 @@
count: notifications_by_work_package.length
} do %>
<table <%= placeholder_table_styles %>>
- <% notifications_by_work_package.each do | notification | %>
- <% if notification.journal.notes.present? %>
- <tr>
- <td style="color: #878787; line-height: 24px; font-size: 14px; white-space: normal;">
- <%= digest_comment_text(notification) %>
- <%= digest_notification_timestamp_text(notification) %>
- </td>
- </tr>
- <% end %>
- <% notification.journal.details.each do |detail| %>
- <tr>
- <td style="color: #878787; line-height: 24px; font-size: 14px; white-space: normal;">
- <%= notification.journal.render_detail(detail, only_path: false) %>
- <%= digest_notification_timestamp_text(notification) %>
- </td>
- </tr>
- <% end %>
- <% end %>
+ <tr>
+ <td style="color: #878787; line-height: 24px; font-size: 14px; white-space: normal;">
+ <%= digest_notification_timestamp_text(notifications_by_work_package.first) %>
+ <%= digest_additional_author_text(notifications_by_work_package) %>
+ </td>
+ </tr>
</table>
<% end %>
<% end %>
diff --git a/app/views/digest_mailer/work_packages.text.erb b/app/views/digest_mailer/work_packages.text.erb
index 7bd18a54828..4d2d3e50233 100644
--- a/app/views/digest_mailer/work_packages.text.erb
+++ b/app/views/digest_mailer/work_packages.text.erb
@@ -7,28 +7,11 @@
<%= "=" * (('# ' + 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) %>
+
+ <% unique_reasons = unique_reasons_of_notifications(notifications_by_work_package) %>
+ <% unique_reasons.each_with_index do |reason, index| %><%= I18n.t(:"mail.work_packages.reason.#{reason || :unknown}", default: '-') %><%= ', ' unless unique_reasons.size-1 == index %><% end %>: <%= digest_notification_timestamp_text(notifications_by_work_package.first, html: false) %>
+ <%= digest_additional_author_text(notifications_by_work_package) %>
- <% notifications_by_work_package.each do | notification | %>
- <%= "-" * 20 %>
-
- <% unique_reasons = unique_reasons_of_notifications(notifications_by_work_package) %>
- <%= digest_notification_timestamp_text(
- notification,
- html: false,
- 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? %>
- <%= I18n.t(:label_comment_added) %>:
- <%= journal.notes %>
-
- <% end %>
- <% journal.details.each do |detail| %>
- * <%= journal.render_detail(detail, only_path: false, no_html: true) %>
- <% end %>
-
- <%= "-" * 20 %>
- <% end %>
<% end %>
<%= "-" * 100 %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index d552c4d832c..f4843f2a142 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1983,9 +1983,7 @@ en:
settings: 'Change email settings'
salutation: 'Hey %{user}!'
work_packages:
- comment_added: '<b>Comment</b> added'
- created: 'Created'
- created_at: 'at %{timestamp} by %{user} '
+ created_at: 'Created 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'
@@ -2000,8 +1998,8 @@ en:
subscribed: 'all'
prefix: 'Received because of the notification setting: %{reason}'
see_all: 'See all'
- updated: 'Updated'
- updated_at: 'at %{timestamp} by %{user}'
+ updated_at: 'Updated 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"