refactor: Drop redundant author re-fetches on the post write paths #44
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
rosa/vernier!44
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refactor/no-author-refetch"
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?
Closes #37.
The post write paths fetched the author from the repository when the caller already held that
User:update_postanddelete_postverifiedcurrent_user.id() == post.user_id(), then fetched the author by the post'suser_id— after that check, the author iscurrent_user.create_postfetched the author by id when both callers (the web handler viaAuthUser, andmicropub_createviaauth.user) already held theUser.Changes
update_post/delete_post: the author iscurrent_user, bound with a one-line comment stating why; thefind_user_by_idround-trip and its impossible "Post author not found" error branch are gone.create_posttakesauthor: &Userinstead of&UserId; the web handler passes¤t_userandmicropub_createpasses&auth.user.make_postand the directcreate_postcalls) pass theUserthey already had fromregister.Each post write saves one repository round-trip.
Verification
mise run cipasses: clippy-D warnings, fmt, sqlx prepare check, all 151 domain tests and the integration suite (which covers web + Micropub create/update/delete end to end, including the webmention dispatch that consumes the author).