Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-6810 Don't send "Automatically flagged as spam" email when hiding works manually #4947

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

EchoEkhi
Copy link
Contributor

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-6810

Purpose

When manually hiding a work that has been marked as spam by Akismet or otherwise, don't send the "Automatically flagged as spam" email, send the "Your work has been hidden by the Policy & Abuse team" email.

Testing Instructions

See JIRA ticket.

Credit

EchoEkhi (He/him)

@EchoEkhi EchoEkhi changed the title AO3-6810 Add work.hidden_for_spam virtual attribute AO3-6810 Don't send "Automatically flagged as spam" email when hiding works manually Oct 19, 2024
Copy link
Contributor

@Bilka2 Bilka2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please action the comments by reviewdog, thank you!

Edit: I removed the rest of my review comments - my alternative approach didn't work, but I think the current approach is also problematic because it's prone to someone forgetting to set the attribute.

@sarken
Copy link
Collaborator

sarken commented Nov 9, 2024

Would it help if we put the hide_spam and bulk_review(ids) methods in charge of sending the admin_spam_work_notification email instead?

I thought notify_of_hiding would also need return if spam? && saved_change_to_spam? to go with that change, but the test seems to pass without it, so I'm not sure.

Speaking of tests, though, I think we should probably also test which emails are sent when using the bulk hiding option on the Moderated Works page. It looks like the current tests only cover the option on the work itself.

@EchoEkhi
Copy link
Contributor Author

I don't think the return if spam? && saved_change_to_spam? works, since it's effectively a rising edge detector, and the decision to send which email is not dependent on whether if there was a rising edge (spam changed from false to true), instead it only depends on which button the admin clicks.

I initially chose the approach of a virtual attribute because the alternative of changing the notify_of_hiding function to not be a after_save hook and instead have individual controllers call either notify_of_hiding or notify_of_hiding_for_spam could result in a situation where if a coder makes a mistake and forgets to call either of these functions when hiding a work, no emails would be sent at all and the user would not be aware that anything had happened. Whereas if the coder makes the mistake of forgetting to set the virtual attribute, the wrong email would be sent, but at least there would be an email.

I have changed the virtual attribute to be internal to the model. Instead of setting the attribute, the coder calls the notify_of_hiding_for_spam to send the hidden-for-spam emails, and that function would also set the attribute to prevent the normal hidden-by-admin emails from being sent. This way it's not possible for a coder to make a mistake in the future and cause a situation where no emails are sent when the work is hidden since the hidden-by-admin email is sent by default.

@EchoEkhi
Copy link
Contributor Author

EchoEkhi commented Nov 21, 2024

ps. I think that test might be flaky

@EchoEkhi
Copy link
Contributor Author

nevermind it was my fault, fixed it now

@Bilka2 Bilka2 requested a review from brianjaustin December 10, 2024 20:04
Copy link
Member

@brianjaustin brianjaustin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple suggestions in addition to the Rubocop

features/admins/admin_spam.feature Outdated Show resolved Hide resolved
app/models/work.rb Outdated Show resolved Hide resolved
Copy link
Member

@brianjaustin brianjaustin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants