refactor: Drop redundant author re-fetches on the post write paths #37
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
rosa/vernier#37
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The post write paths fetch the author from the repository when the caller already holds that
User:update_post(crates/domain/src/services.rs:1006-1016) verifiescurrent_user.id() == old_post.user_id(), then fetches the author byold_post.user_id()— after that check, the author iscurrent_user.delete_post(services.rs:1052-1062) — same pattern.create_post(services.rs:499-505) fetches the author byuser_id, but both callers (the web handler viaAuthUser, andmicropub_createviaauth.user) already hold theUser.Proposal
update_post/delete_post: drop thefind_user_by_idround-trip and usecurrent_useras the author forpost_source_url.create_post: take&Userinstead of&UserId.Each change removes a DB round-trip per write and an impossible "Post author not found" error branch.