-
Notifications
You must be signed in to change notification settings - Fork 652
AO3-7238 Add work's last updated time to akismet comment spam checks #5521
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
base: master
Are you sure you want to change the base?
Conversation
|
I think tests similar to these tests of various akismet_attributes' values would be fine. Maybe we could use |
app/models/comment.rb
Outdated
| comment_post_modified_gmt = ultimate_parent.revised_at.to_i | ||
| else | ||
| comment_type = "comment" | ||
| comment_post_modified_gmt = ultimate_parent.created_at.to_i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe Akismet wants the timestamp in ISO 8601 format
78815fc to
8f953ce
Compare
marcus8448
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
| # works or admin posts. | ||
| comment_type = ultimate_parent.is_a?(Work) ? "fanwork-comment" : "comment" | ||
| case ultimate_parent | ||
| when ->(p) { p.is_a?(Work) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| when ->(p) { p.is_a?(Work) } | |
| when Work |
| it "has comment_post_modified_gmt as the work's revision time", :frozen do | ||
| work_posted_at = Time.current | ||
| travel_to(1.day.from_now) do | ||
| Chapter.new work_id: subject.commentable.id | ||
| expect(subject.akismet_attributes[:comment_post_modified_gmt]).to eq(Time.current.iso8601) | ||
| expect(subject.akismet_attributes[:comment_post_modified_gmt]).not_to eq(work_posted_at.iso8601) | ||
| end | ||
| end | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, this test isn't really checking what it looks like - subject is loaded lazily so the work is created within the time travel block. Chapter.new also doesn't automatically save the record, so the new chapter is never actually attached to the work (I believe we generally prefer to use factory bot's create which does save automatically).
I think it would be clearer (for all the tests) to compare directly to the records' revised_at/created_at time instead of freezing and comparing to now.
Pull Request Checklist
as the first thing in your pull request title (e.g.
AO3-1234 Fix thing)until they are reviewed and merged before creating new pull requests.
Issue
https://otwarchive.atlassian.net/browse/AO3-7238
Purpose
Adds the timestamp of modification of the parent which the comment was posted on (revision time for works and creation time for admin posts). It is to improve akismet's comment checks for better spam detection accuracy.
Credit
ömer faruk (he/him)