Skip to content

Commit b3c71b3

Browse files
committed
AO3-5350 I18n admin_spam_work_notification
1 parent fd5046c commit b3c71b3

File tree

7 files changed

+47
-8
lines changed

7 files changed

+47
-8
lines changed

app/mailers/user_mailer.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def admin_spam_work_notification(creation_id, user_id)
369369

370370
mail(
371371
to: @user.email,
372-
subject: "[#{ArchiveConfig.APP_SHORT_NAME}] Your work was hidden as spam"
372+
subject: default_i18n_subject(app_name: ArchiveConfig.APP_SHORT_NAME)
373373
)
374374
end
375375

app/models/work.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,9 @@ def notify_of_hiding
11681168

11691169
def notify_of_hiding_for_spam
11701170
users.each do |user|
1171-
UserMailer.admin_spam_work_notification(id, user.id).deliver_after_commit
1171+
I18n.with_locale(user.preference.locale.iso) do
1172+
UserMailer.admin_spam_work_notification(id, user.id).deliver_after_commit
1173+
end
11721174
end
11731175
self.notified_of_hiding_for_spam = true
11741176
end
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<% content_for :message do %>
22
<p><%= t("mailer.general.greeting.formal_html", name: style_bold(@user.login)) %></p>
33

4-
<p>Your work <%= style_creation_link(@work.title, @work) %> has been flagged by our automated system as spam and hidden until it can be reviewed by our Policy & Abuse team. While the work is hidden it can only be accessed by you and AO3 site admins.</p>
4+
<p><%= t(".flagged_as_spam.html", work_link: style_creation_link(@work.title, @work)) %></p>
55

6-
<p>If we determine that your work is not spam, we'll unhide it. Other users will then be able to access and leave feedback on it as usual. Please note that we do not screen works for other kinds of violations at this time. If your work is reported to us for a different reason in the future, that will be investigated separately.</p>
6+
<p><%= t(".future") %></p>
77

8-
<p>If you have any questions, please <%= abuse_link("contact our Policy & Abuse Team") %>.</p>
8+
<p><%= t(".questions.html", contact_abuse_link: abuse_link(t(".contact_abuse"))) %></p>
99
<% end %>
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<% content_for :message do %>
22
<%= t("mailer.general.greeting.formal_html", name: @user.login) %>
33

4-
Your work "<%= @work.title.html_safe %>" (<%= work_url(@work) %>) has been flagged by our automated system as spam and hidden until it can be reviewed by our Abuse team. While the work is hidden it can only be accessed by you and AO3 site admins.
4+
<%= t(".flagged_as_spam.text", work_title: @work.title, work_url: work_url(@work)) %>
55

6-
If we determine that your work is not spam, we'll unhide it. Other users will then be able to access and leave feedback on it as usual. Please note that we do not screen works for other kinds of violations at this time. If your work is reported to us for a different reason in the future, that will be investigated separately.
6+
<%= t(".future") %>
77

8-
If you have any questions, please contact our Policy & Abuse team (<%= new_abuse_report_url %>).
8+
<%= t(".questions.text", contact_abuse_url: new_abuse_report_url) %>
99
<% end %>

config/locales/mailers/en.yml

+10
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ en:
134134
tos_violation:
135135
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.
136136
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.
137+
admin_spam_work_notification:
138+
contact_abuse: contact our Policy & Abuse Team
139+
flagged_as_spam:
140+
html: Your work %{work_link} has been flagged by our automated system as spam and hidden until it can be reviewed by our Policy & Abuse team. While the work is hidden it can only be accessed by you and AO3 site admins.
141+
text: Your work "%{work_title}" (%{work_url}) has been flagged by our automated system as spam and hidden until it can be reviewed by our Abuse team. While the work is hidden it can only be accessed by you and AO3 site admins.
142+
future: If we determine that your work is not spam, we'll unhide it. Other users will then be able to access and leave feedback on it as usual. Please note that we do not screen works for other kinds of violations at this time. If your work is reported to us for a different reason in the future, that will be investigated separately.
143+
questions:
144+
html: If you have any questions, please %{contact_abuse_link}.
145+
text: If you have any questions, please contact our Policy & Abuse team (%{contact_abuse_url}).
146+
subject: "[%{app_name}] Your work was hidden as spam"
137147
anonymous_or_unrevealed_notification:
138148
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."
139149
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."

features/admins/admin_spam.feature

+21
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,24 @@ Scenario: Review spam when spam works are not already hidden
5151
And the work "Totally Legit" should not be hidden
5252
And 1 email should be delivered
5353
And the email should contain "has been flagged by our automated system as spam"
54+
55+
Scenario: Translated work hidden as spam email
56+
Given I am logged in as "spammer"
57+
And I post the work "Spammity Spam Work"
58+
And a locale with translated emails
59+
And the user "spammer" enables translated emails
60+
And I add the co-author "Another" to the work "Spammity Spam Work"
61+
When I am logged in as a "policy_and_abuse" admin
62+
And all emails have been delivered
63+
And I view the work "Spammity Spam Work"
64+
Then I should see "Mark As Spam"
65+
When I follow "Mark As Spam"
66+
Then I should see "marked as spam and hidden"
67+
And I should see "Mark Not Spam"
68+
And the work "Spammity Spam Work" should be marked as spam
69+
And the work "Spammity Spam Work" should be hidden
70+
And 2 emails should be delivered
71+
And the email to "spammer" should contain "has been flagged by our automated system as spam"
72+
And the email to "spammer" should be translated
73+
And the email to "Another" should contain "has been flagged by our automated system as spam"
74+
And the email to "Another" should be non-translated

test/mailers/previews/user_mailer_preview.rb

+6
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ def archivist_added_to_collection_notification
159159
UserMailer.archivist_added_to_collection_notification(user.id, work.id, collection.id)
160160
end
161161

162+
def admin_spam_work_notification
163+
work = create(:work)
164+
user = create(:user, :for_mailer_preview)
165+
UserMailer.admin_spam_work_notification(work.id, user.id)
166+
end
167+
162168
def admin_hidden_work_notification
163169
work = create(:work)
164170
user = create(:user, :for_mailer_preview)

0 commit comments

Comments
 (0)