diff --git a/app/mailers/app_mailer.rb b/app/mailers/app_mailer.rb index 2da65a0e6..6ae4b1f43 100644 --- a/app/mailers/app_mailer.rb +++ b/app/mailers/app_mailer.rb @@ -8,9 +8,15 @@ class AppMailer < Devise::Mailer def notification(user, notification, opts = {}) @user = user @notification = notification + subject = + if notification.deliver? + subject = I18n.t('notifications.deliver.email_subject') + else + subject = I18n.t('notifications.email_title') + end headers = { to: @user.email, - subject: I18n.t('notifications.email_title') + subject: subject }.merge(opts) mail(headers) end diff --git a/app/views/user_notifications/_list.html.erb b/app/views/user_notifications/_list.html.erb index b178eb735..a9e6a40e2 100644 --- a/app/views/user_notifications/_list.html.erb +++ b/app/views/user_notifications/_list.html.erb @@ -9,6 +9,9 @@
<%= sanitize_input(notification.title) %>
+ <% if notification.deliver? %> + Click the link to download the file.
+ <% end %> <%= l(notification.created_at, format: :full) %> | <%= sanitize_input(notification.message) %>
diff --git a/app/views/user_notifications/_recent_notifications.html.erb b/app/views/user_notifications/_recent_notifications.html.erb index f93b736db..c8a49f456 100644 --- a/app/views/user_notifications/_recent_notifications.html.erb +++ b/app/views/user_notifications/_recent_notifications.html.erb @@ -9,6 +9,9 @@
<%= sanitize_input(notification.title) %>
+ <% if notification.deliver? %> + Click the link to download the file.
+ <% end %> <%= l(notification.created_at, format: :full) %> | <%= sanitize_input(notification.message) %>
diff --git a/app/views/users/mailer/notification.html.erb b/app/views/users/mailer/notification.html.erb index b5731aeb1..30ae6939b 100644 --- a/app/views/users/mailer/notification.html.erb +++ b/app/views/users/mailer/notification.html.erb @@ -1,13 +1,16 @@ -

Hello <%= @user.name %>!

+

Hello <%= @user.name %>,

-

<%= I18n.t("notifications.email_title") %>

- -

Type: <%= I18n.t("notifications.types.#{@notification.type_of}") %>

+<% unless @notification.deliver? %> +

<%= I18n.t("notifications.email_title") %>

+

Type: <%= I18n.t("notifications.types.#{@notification.type_of}") %>

+<% end %>

- <% if @notification.system_message? || @notification.deliver? %> + <% if @notification.system_message? %> <% # We assume the system notification is clean %> <%= @notification.title.html_safe %> + <% elsif @notification.deliver? %> + <%= I18n.t("notifications.deliver.email_body").html_safe %> <% else %> <%= sanitize_input(prepend_server_url_to_links(@notification.title)) %> <% end %> @@ -18,8 +21,12 @@ <% # We assume the system notification is clean %> <%= @notification.message.html_safe %> <% elsif @notification.deliver? %> +

+ <%= I18n.t("notifications.deliver.email_end_greeting").html_safe %> +

<% # work around the problem with inserting the link of zipExport %> <% zip_id = /data-id='(\d*)'/.match(@notification.message)[1] %> + <%= I18n.t("notifications.deliver.download_link") %> <%= @notification.message.gsub(/href='.+'/, "href='#{zip_exports_download_url(zip_id)}'").html_safe %> <% else %> <%= sanitize_input(prepend_server_url_to_links(@notification.message)) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 8dee84d14..399d4dd2d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1811,6 +1811,11 @@ en: recent_notification_description: 'Recent changes notifications appear whenever there is a change on a task you are assigned to.' system_message: 'System message' system_message_description: 'System message notifications are specifically sent by site maintainers to notify all users about a system update.' + deliver: + download_link: "Download link:" + email_subject: "Your SciNote export is ready!" + email_body: "

The export of SciNote project(s) that you requested is ready!

You can find the link to download the file below or in your SciNote notifications. Please keep in mind that the link will expire in 7 days for security reasons.

" + email_end_greeting: "

Best regards,

Your SciNote team

" show_all: "Show all notifications" show_more: "Show more notifications" no_notifications: "No notifications." @@ -1878,7 +1883,7 @@ en: zip_export: modal_label: 'Export inventory' - notification_title: 'Your package is ready to be exported!' + notification_title: 'Your requested export package is ready!' expired_title: 'Looks like your link has expired.' expired_description: 'Please export the data again in order to receive a new link.' modal_label: 'Export request received'