refactor: extract activity dispatcher middleware to eliminate handler boilerplate #10
Reference in New Issue
Block a user
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
All 13 activity handlers in
activities/*.rsrepeat the same pattern:check_guards()→ parse actor/object → call repos → log. TheActivitytrait interface is nearly as complex as each implementation. Every handler independently calls intodata.follow_repo,data.blocklist_repo, etc.To understand a single flow (e.g. "how does a Follow get accepted") you must jump between
follow.rs→accept.rs→follow_repotrait →service/follow.rs. Testing a single activity requires mocking 5+ repositories.Proposal
Extract a unified activity dispatcher/middleware that:
check_guards()(dedup + domain blocklist) once for all activitiesreceive()logicBefore
After
Files
src/activities/*.rs(all 13 handlers)src/activities/helpers.rssrc/inbox.rsTrade-offs
Dependency
Should be done before #10 (Undo dispatcher) since Undo's match arms would become registered handlers.