Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

AO3-5251: Add spam-specific hidden work email #3171

Merged
merged 2 commits into from Nov 20, 2017
Jump to file or symbol
Failed to load files and symbols.
+51 −10
Split
View
@@ -366,6 +366,16 @@ def admin_hidden_work_notification(creation_id, user_id)
)
end
+ def admin_spam_work_notification(creation_id, user_id)
+ @user = User.find_by(id: user_id)
+ @work = Work.find_by(id: creation_id)
+
+ mail(
+ to: @user.email,
@houndci-bot

houndci-bot Nov 19, 2017

Indent the first parameter one step more than the start of the previous line.

+ subject: "[#{ArchiveConfig.APP_SHORT_NAME}] Your work was hidden as spam"
+ )
+ end
+
### OTHER NOTIFICATIONS ###
# archive feedback
View
@@ -1422,7 +1422,11 @@ def mark_as_ham!
def notify_of_hiding
return unless hidden_by_admin? && saved_change_to_hidden_by_admin?
users.each do |user|
- UserMailer.admin_hidden_work_notification(id, user.id).deliver
+ if spam?
+ UserMailer.admin_spam_work_notification(id, user.id).deliver
+ else
+ UserMailer.admin_hidden_work_notification(id, user.id).deliver
+ end
end
end
@@ -28,15 +28,12 @@
<dt><%= f.label :days_to_purge_unactivated, ts("How many weeks you have to activate your account before we purge it") %></dt>
<dd><%= f.text_field :days_to_purge_unactivated, :size => "3" %></dd>
-
- <dt><%= f.check_box :hide_spam %></dt>
- <dd><%= f.label :hide_spam, ts("Automatically hide spam works") %></dd>
</dl>
</fieldset>
<fieldset>
- <legend><%= ts("Performance") %></legend>
- <h3 class="landmark heading"><%= ts("Performance") %></h3>
+ <legend><%= ts("Performance and Misc") %></legend>
+ <h3 class="landmark heading"><%= ts("Performance and Misc") %></h3>
<dl>
<dt><%= f.check_box :disable_filtering %></dt>
@@ -59,6 +56,9 @@
<dt><%= f.label :cache_expiration, ts("How often (in minutes) should we refresh caching") %></dt>
<dd><%= f.text_field :cache_expiration, :size => "3" %></dd>
+
+ <dt><%= f.check_box :hide_spam %></dt>
+ <dd><%= f.label :hide_spam, ts("Automatically hide spam works") %></dd>
</dl>
</fieldset>
@@ -0,0 +1,12 @@
+<% content_for :message do %>
+ <p>Dear <%= @user.default_pseud.byline %>,</p>
+
+ <p>Your work <i><%= style_link(@work.title.html_safe, work_url(@work)) %></i> 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.</p>
+
+ <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>
+
+ <p>If you have any questions, please <%= abuse_link("contact our Abuse Team") %>.</p>
+
+ <p>Sincerely,</p>
+ <p><%= style_bold("AO3 Abuse") %></p>
+<% end %>
@@ -0,0 +1,12 @@
+<% content_for :message do %>
+ Dear <%= @user.default_pseud.byline %>,
+
+ 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.
+
+ 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.
+
+ If you have any questions, please contact our Abuse Team (<%= new_abuse_report_url %>).
+
+ Sincerely,
+ AO3 Abuse
+<% end %>
View
@@ -229,17 +229,20 @@
before do
@admin_setting.update_attribute(:hide_spam, true)
end
- it "automatically hides spam works" do
- @work.update_attributes!(spam: true)
+ it "automatically hides spam works and sends an email" do
+ expect { @work.update_attributes!(spam: true) }.
+ to change { ActionMailer::Base.deliveries.count }.by(1)
expect(@work.reload.hidden_by_admin).to be_truthy
+ expect(ActionMailer::Base.deliveries.last.subject).to eq("[AO3] Your work was hidden as spam")
end
end
context "when the admin setting is disabled" do
before do
@admin_setting.update_attribute(:hide_spam, false)
end
- it "does not automatically hide spam works" do
- @work.update_attributes!(spam: true)
+ it "does not automatically hide spam works and does not send an email" do
+ expect { @work.update_attributes!(spam: true) }.
@houndci-bot

houndci-bot Nov 19, 2017

Parenthesize the param change { ActionMailer::Base.deliveries.count } to make sure that the block will be associated with the change method call.

+ not_to change { ActionMailer::Base.deliveries.count }
expect(@work.reload.hidden_by_admin).to be_falsey
end
end