Skip to content

Conversation

@ihorsokhanexoft
Copy link
Contributor

@ihorsokhanexoft ihorsokhanexoft commented Nov 19, 2025

Purpose

Admin encounters cases when spam data is not set for the objects that have SPAM status

Changes

When user is being checked for spam, it doesn't set spam data of the user to this related resources
Some objects become FLAGGED instead of SPAM when spam is found by akismet and oopspam
Also fixed losing FLAGGED status of user after account deactivation
It happens when:

  1. Spammy domains are found in user record and they aren't added to user's nodes and preprints
  2. Spam is found by akismet or oops. In this case spam data is not set for related objects at all

Ticket

https://openscience.atlassian.net/browse/ENG-9730?atlOrigin=eyJpIjoiYTI3ZWU1MDRhZjc1NDVhOGIyNjljNjYyY2Q3OGZjOGIiLCJwIjoiaiJ9

@cslzchen cslzchen changed the base branch from master to hotfix/25.18.2 December 10, 2025 15:33
Copy link
Collaborator

@cslzchen cslzchen left a comment

Choose a reason for hiding this comment

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

LGTM ⭐

As someone who is not familiar with how spam works, I had had a hard time understanding your code until I saw your unit tests. 🥇

Comment on lines +2411 to +2427
"""
This method makes the next checks when akismet and oopsystem are used:
1. A resource and its creator become FLAGGED and other public nodes/preprints of this creator become SPAMMED and contain the same spam data
2. Private nodes/preprints don't contain spam data
3. If akismet confirms spam, all objects from #1 have spam_pro_tip
4. If oopspam confirms spam, all objects from #1 have oopspam_data key in spam_data
5. who_flagged property in spam_data contains either service name (akismet or oopspam) or 'both' value
6. spam_data of objects from #1 contains headers, request user info and spammy content

Params:
spam_object - object that is being checked for spam
akismet_spam_data - spam data returned by akismet
oops_spam_data - spam data returned by oopsystem
objects_to_be_spammed - objects to be spammed instead of flagged. Example:
spam_object = Node
spam objects is flagged, its creator is flagged and the others user's public nodes/preprints must be spammed
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 for this docstring (and the comprehensive unit tests you added), which actually helped me understand the your code

@cslzchen cslzchen merged commit ae5e88f into CenterForOpenScience:hotfix/25.18.2 Dec 11, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants