refactor: Extract shared feed assembly from the RSS and Atom handlers #41
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
rosa/vernier#41
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
get_user_rss(crates/web/src/handlers/users.rs:511-579) andget_user_atom(:581-655) duplicate the whole feed-assembly pipeline: fetch user by name, fetch published posts, hand-format the/u/{user}/{slug}permalink, join againstbase_url, and unwrappublished_atwith the same "post from find_posts_published_by_user did not have a published_at date" error. Only the final rendering (rss vs atom_syndication builders) differs.Proposal
Extract the shared assembly into one step that produces format-agnostic feed data, e.g.:
Each handler then maps
FeedDatainto its format-specific builders. Thepublished_atinvariant gets asserted in one place, and permalink construction drops to a single site (or calls the shared permalinks module if that lands first).Related
Depends usefully on (but is not blocked by) the permalinks-module issue.
Superseded by #101, which describes the same refactor against the current code.
This issue's description has gone stale. Since it was filed, intervening domain work has already resolved most of the duplication it called out:
resolve_profile(&username, None)call shared by both handlers.published_atunwrap invariant ("post ... did not have a published_at date") is gone — the handlers callpost.published_at()directly, with the invariant enforced in the domain layer.permalinks::helpers.What remains is the narrower duplication #101 captures accurately (the per-post loop,
blog_urlconstruction, and content-type header shared by the RSS and Atom handlers). Consolidating there. Closing this as a duplicate.