-
-
Notifications
You must be signed in to change notification settings - Fork 860
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore old federated post edits (ref #4529) #4586
Conversation
crates/apub/src/objects/comment.rs
Outdated
.map(|c| c.updated.unwrap_or(c.published)) | ||
.clone() | ||
.ok(); | ||
verify_object_timestamp(old_timestamp, note.updated.or(note.published))?; |
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.
Unfortunately this is rather verbose, no way to avoid that unless we add a trait (which would be even more verbose and wouldnt be used anywhere else).
The timestamp should be checked by calling If you don't want |
This looks generally fine to me, but I agree with dullbanas that filter the verify might not be the right place to do it? To clarify on their second point, if you do it here you have a race condition where if two updates are processed simultaneously then the "verify" of the second can be called after the db update of the first, which then causes the older update to override the newer one. The only guaranteed way to do this correctly is if the filtering happens as a WHERE in the update query. |
Good suggestion, Ive changed it like that. Also added separate |
41bac92
to
974dca5
Compare
.filter_target(coalesce(comment::updated, comment::published).lt(timestamp)) | ||
.do_update() | ||
.set(comment_form) | ||
.get_result::<Self>(conn) |
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.
not sure but I think this will result in an error if the value is not updated? as in, the query will return zero rows which will cause get_result to return a row not found error unless you add .optional()
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.
Correct
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.
That should be fine, if we are receiving an old comment while already storing a newer one, it throws an error and gets rejected. We dont need to do anything in that case.
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.
Assuming @Nutomic is correct about returning an error when skipping update
No description provided.