diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 734e27b08f..7039b4f0bb 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -359,12 +359,10 @@ def admin_hidden_work_notification(creation_id, user_id) @user = User.find_by(id: user_id) @work = Work.find_by(id: creation_id) - I18n.with_locale(@user.preference.locale.iso) do - mail( - to: @user.email, - subject: default_i18n_subject(app_name: ArchiveConfig.APP_SHORT_NAME) - ) - end + mail( + to: @user.email, + subject: default_i18n_subject(app_name: ArchiveConfig.APP_SHORT_NAME) + ) end def admin_spam_work_notification(creation_id, user_id) diff --git a/app/models/work.rb b/app/models/work.rb index aaf904c38a..7b59f863fe 100755 --- a/app/models/work.rb +++ b/app/models/work.rb @@ -1154,7 +1154,9 @@ def notify_of_hiding return if notified_of_hiding_for_spam users.each do |user| - UserMailer.admin_hidden_work_notification(id, user.id).deliver_after_commit + I18n.with_locale(user.preference.locale.iso) do + UserMailer.admin_hidden_work_notification(id, user.id).deliver_after_commit + end end end diff --git a/app/views/user_mailer/admin_hidden_work_notification.html.erb b/app/views/user_mailer/admin_hidden_work_notification.html.erb index 774f1712ca..80552e23a8 100644 --- a/app/views/user_mailer/admin_hidden_work_notification.html.erb +++ b/app/views/user_mailer/admin_hidden_work_notification.html.erb @@ -1,13 +1,13 @@ <% content_for :message do %>

<%= t("mailer.general.greeting.formal_html", name: style_bold(@user.login)) %>

-

<%= t(".html.hidden", title: style_creation_link(@work.title, @work)).html_safe %>

+

<%= t(".hidden.html", title: style_creation_link(@work.title, @work)) %>

<%= t(".access") %>

<%= t(".check_email") %>

-

<%= t(".html.tos_violation", tos_link: tos_link(t ".tos")).html_safe %>

+

<%= t(".tos_violation.html", tos_link: tos_link(t(".tos"))) %>

-

<%= t(".html.help", contact_abuse_link: abuse_link(t ".contact_abuse")).html_safe %>

+

<%= t(".help.html", contact_abuse_link: abuse_link(t(".contact_abuse"))) %>

<% end %> diff --git a/app/views/user_mailer/admin_hidden_work_notification.text.erb b/app/views/user_mailer/admin_hidden_work_notification.text.erb index be24bfc03f..834e2b9359 100644 --- a/app/views/user_mailer/admin_hidden_work_notification.text.erb +++ b/app/views/user_mailer/admin_hidden_work_notification.text.erb @@ -1,13 +1,13 @@ <% content_for :message do %> <%= t("mailer.general.greeting.formal_html", name: @user.login) %> -<%= t(".text.hidden", title: @work.title, work_url: work_url(@work)) %> +<%= t(".hidden.text", title: @work.title, work_url: work_url(@work)) %> <%= t(".access") %> <%= t(".check_email") %> -<%= t(".text.tos_violation", tos_url: tos_url) %> +<%= t(".tos_violation.text", tos_url: tos_url) %> -<%= t(".text.help", contact_abuse_url: new_abuse_report_url) %> +<%= t(".help.text", contact_abuse_url: new_abuse_report_url) %> <% end %> diff --git a/config/locales/mailers/en.yml b/config/locales/mailers/en.yml index 0374689a42..6b84ef9df2 100644 --- a/config/locales/mailers/en.yml +++ b/config/locales/mailers/en.yml @@ -124,16 +124,17 @@ en: access: While your work is hidden, you will still be able to access it through the link provided above, but it will not be listed on your works page, and it won't be available to other users of the Archive. check_email: Please check your email, including your spam folder, as the Policy & Abuse team may have already contacted you explaining why your work was hidden. contact_abuse: contact Policy & Abuse - html: - help: If you are uncertain why your work was hidden, and you have not received further communication regarding this matter, please %{contact_abuse_link} directly. - hidden: Your work %{title} has been hidden by the Policy & Abuse team and is no longer publicly accessible. - tos_violation: If your work was hidden due to being in violation of the Archive of Our Own's %{tos_link}, you will be required to take action to correct the violation. Failure to bring your work into compliance with the Terms of Service may lead to your work being deleted from the Archive. + help: + html: If you are uncertain why your work was hidden, and you have not received further communication regarding this matter, please %{contact_abuse_link} directly. + text: 'If you are uncertain why your work was hidden, and you have not received further communication regarding this matter, please contact Policy & Abuse directly: %{contact_abuse_url}.' + hidden: + html: Your work %{title} has been hidden by the Policy & Abuse team and is no longer publicly accessible. + text: Your work "%{title}" (%{work_url}) has been hidden by the Policy & Abuse team and is no longer publicly accessible. subject: "[%{app_name}] Your work has been hidden by the Policy & Abuse team" - text: - help: 'If you are uncertain why your work was hidden, and you have not received further communication regarding this matter, please contact Policy & Abuse directly: %{contact_abuse_url}.' - hidden: Your work "%{title}" (%{work_url}) has been hidden by the Policy & Abuse team and is no longer publicly accessible. - tos_violation: If your work was hidden due to being in violation of the Archive of Our Own's Terms of Service (%{tos_url}), you will be required to take action to correct the violation. Failure to bring your work into compliance with the Terms of Service may lead to your work being deleted from the Archive. tos: Terms of Service + tos_violation: + html: If your work was hidden due to being in violation of the Archive of Our Own's %{tos_link}, you will be required to take action to correct the violation. Failure to bring your work into compliance with the Terms of Service may lead to your work being deleted from the Archive. + text: If your work was hidden due to being in violation of the Archive of Our Own's Terms of Service (%{tos_url}), you will be required to take action to correct the violation. Failure to bring your work into compliance with the Terms of Service may lead to your work being deleted from the Archive. anonymous_or_unrevealed_notification: anonymous_info: Anonymous works are included in tag listings, but not on your works page. On the work, your user name will be replaced with "Anonymous." anonymous_unrevealed_info: The collection maintainers may later reveal your work but leave it anonymous. People who subscribe to you will not be notified of this change. Your work will be included in tag listings, but not on your works page. On the work, your user name will be replaced with "Anonymous." diff --git a/features/admins/admin_works.feature b/features/admins/admin_works.feature index b89227e8b6..9491c6935b 100644 --- a/features/admins/admin_works.feature +++ b/features/admins/admin_works.feature @@ -16,16 +16,21 @@ Feature: Admin Actions for Works, Comments, Series, Bookmarks Scenario Outline: Can hide works Given I am logged in as "regular_user" And I post the work "ToS Violation" + And a locale with translated emails + And the user "regular_user" enables translated emails + And I add the co-author "Another" to the work "ToS Violation" When I am logged in as a "" admin And all emails have been delivered And I view the work "ToS Violation" And I follow "Hide Work" Then I should see "Item has been hidden." - And logged out users should not see the hidden work "ToS Violation" by "regular_user" - And logged in users should not see the hidden work "ToS Violation" by "regular_user" + And the work "ToS Violation" should be hidden And "regular_user" should see their work "ToS Violation" is hidden - And 1 email should be delivered - And the email should contain "you will be required to take action to correct the violation" + And 2 emails should be delivered + And the email to "regular_user" should contain "you will be required to take action to correct the violation" + And the email to "regular_user" should be translated + And the email to "Another" should contain "you will be required to take action to correct the violation" + And the email to "Another" should be non-translated Examples: | role | diff --git a/test/mailers/previews/user_mailer_preview.rb b/test/mailers/previews/user_mailer_preview.rb index 1dd5886da7..89bd16bbb9 100644 --- a/test/mailers/previews/user_mailer_preview.rb +++ b/test/mailers/previews/user_mailer_preview.rb @@ -112,7 +112,7 @@ def change_email new_email = "new_email" UserMailer.change_email(user.id, old_email, new_email) end - + # Sends email when collection item changes status: anonymous_unrevealed def anonymous_or_unrevealed_notification_status_anonymous_and_unrevealed user, collection, item = anonymous_or_unrevealed_data(:anonymous_unrevealed_collection) @@ -123,7 +123,7 @@ def anonymous_or_unrevealed_notification_status_anonymous_and_unrevealed anonymous: newly_anonymous, unrevealed: newly_unrevealed ) end - + # Sends email when collection item changes status: anonymous def anonymous_or_unrevealed_notification_status_anonymous user, collection, item = anonymous_or_unrevealed_data(:anonymous_collection) @@ -134,7 +134,7 @@ def anonymous_or_unrevealed_notification_status_anonymous anonymous: newly_anonymous, unrevealed: newly_unrevealed ) end - + # Sends email when collection item changes status: unrevealed def anonymous_or_unrevealed_notification_status_unrevealed user, collection, item = anonymous_or_unrevealed_data(:unrevealed_collection) @@ -159,6 +159,12 @@ def archivist_added_to_collection_notification UserMailer.archivist_added_to_collection_notification(user.id, work.id, collection.id) end + def admin_hidden_work_notification + work = create(:work) + user = create(:user, :for_mailer_preview) + UserMailer.admin_hidden_work_notification(work, user.id) + end + private def creatorship_notification_data(creation_type) @@ -167,7 +173,7 @@ def creatorship_notification_data(creation_type) creation = create(creation_type, authors: [first_creator.default_pseud, second_creator.default_pseud]) [creation.creatorships.last, first_creator] end - + def anonymous_or_unrevealed_data(status) user = create(:user, :for_mailer_preview) collection = create(status)