Skip to content

AO3-7275 Unreviewed comments marked as spam are still visible to creators#5577

Open
archie-2006 wants to merge 14 commits into
otwcode:masterfrom
archie-2006:spam-visiblity
Open

AO3-7275 Unreviewed comments marked as spam are still visible to creators#5577
archie-2006 wants to merge 14 commits into
otwcode:masterfrom
archie-2006:spam-visiblity

Conversation

@archie-2006
Copy link
Copy Markdown

Updated comment to include not_spam scope
filter unreviewed comments in commentscontroller using not_spam update specs to verify spam comments are excluded from viewing

Pull Request Checklist

Issue

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

Purpose

Unreviewed comments marked as spam remained visible to creators in the unreviewed comments.

  • added a not_spam scope to filter out spam-flagged comments.

  • applied the not_spam scope to the index action for unreviewed comments.

  • while creators have their view filtered, admins retain full visibility of all unreviewed comments for moderation.

  • modified comment_spec.rb to verify the exclusion of spam from these filtered collections.

References

  • fixes the issue where unreviewed spam comments behaved differently than reviewed spam comments for creators.

  • updates the unreviewed comments counter consistently

Credit

Archie Singh (she/her/hers)

Updated comment to include not_spam scope
filter unreviewed comments in commentscontroller using not_spam
update specs to verify spam comments are excluded from viewing
@Bilka2
Copy link
Copy Markdown
Contributor

Bilka2 commented Feb 8, 2026

Hi, Archie Singh!

Thank you so much for this pull request, someone will be along to review it soon.

I've also updated the Jira issue status to In Review so no one will mistakenly create a duplicate pull request. If you'd like the ability to comment on, assign, and transition issues in the future, you're welcome to create a Jira account! It makes things a bit easier for us on the organizational side if the Full Name on your Jira account either closely matches the name you'd like us to credit in the release notes or includes it in parentheses, e.g. "Nickname (CREDIT NAME)."

Once you've done that (or if you've already done it -- Jira has been unreliable about showing us new accounts in the admin panel lately), you can either reply here or send an email to otw-coders@transformativeworks.org with your account name and email address and we'll set up the permissions for you.

Thanks again for contributing! If you have any questions, you can contact us at the same email address listed above.

@Bilka2 Bilka2 changed the title AO3-7275: Unreviewed comments marked as spam are still visible to creators AO3-7275 Unreviewed comments marked as spam are still visible to creators Feb 8, 2026
Copy link
Copy Markdown
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.

Thanks for getting started on this! Please also adjust app/views/works/_work_header_navigation.html.erb to display the correct comment count for users

Comment thread app/models/comment.rb Outdated
Comment thread spec/models/comment_spec.rb Outdated
Comment thread spec/models/comment_spec.rb Outdated
Comment thread spec/models/comment_spec.rb Outdated
Comment thread features/comments_and_kudos/comment_moderation.feature Outdated

Scenario: Creator marks an unreviewed comment as spam and the count updates
Given I have a work "Spam Trap"
And I have "Enable comment moderation" checked on "Spam Trap"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please indent all "And" steps one extra level

Comment thread app/views/works/_work_header_navigation.html.erb Outdated
Comment thread app/views/works/_work_header_navigation.html.erb Outdated
Comment thread app/views/works/_work_header_navigation.html.erb Outdated
Comment thread app/views/works/_work_header_navigation.html.erb Outdated
Comment thread app/models/comment.rb Outdated
@archie-2006
Copy link
Copy Markdown
Author

archie-2006 commented May 17, 2026

Hey @Bilka2 I've pushed the fixes for the model scopes, the redundant RSpec test, and formatting+translations as you had asked for (meanwhile let me see if I can fix the rubocop error on my own).
Thank you

else
@work.find_all_comments.unreviewed_only.not_spam.count
end %>
<%= link_to t("works.work_header_navigation.unreviewed_comments", count: unreviewed_count), unreviewed_work_comments_path(@work) %>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you make this use lazy lookup for the locale, so ".unreviewed_comments"?

Comment on lines -108 to +113
<%# The li, noscript, and button tags MUST be on the same line here to avoid the behavior described in https://otwarchive.atlassian.net/browse/AO3-4629?focusedCommentId=372231 %>
<%# The li, noscript, and button tags MUST be on the same line here %>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like an unrelated change found its way into the file, could you undo it?

Comment thread app/models/comment.rb

Given "the moderated work {string} by {string}" do |title, login|
user = ensure_user(login)
user.preference.update!(allow_co_creator_invite: true)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change is causing the test to fail and seems to be unrelated to this PR, could you remove it?

Comment on lines +341 to +344
And I fill in "Comment" with "Fake spam"
And I fill in "Name" with "Spammer"
And I fill in "Email" with "spam@example.com"
And I press "Comment"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could this be replaced with the I post the comment "..." on "Spam Trap" step?

When I follow "Unreviewed Comments"
And I follow "Spam"
Then I should see "Unreviewed Comments (0)"
And I should not see "Fake spam"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you add some steps that check that for admins the count is still 1 and the comment is visible on the page for unreviewed comments but marked as spam?

Additionally, please address the comment about the indentation of the And steps

Comment on lines +334 to +339
Given I am logged in as "spam_catcher"
And I have a work "Spam Trap"
And I edit the work "Spam Trap"
And I check "Enable comment moderation on this work"
And I press "Post Without Preview"
And I am logged out
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could this be replaced with the the moderated work "Spam Trap" by "spam_catcher" step?

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.

2 participants