refactor: consolidate DbActor construction into a single factory #13
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
DbActorhas 4 different construction paths:get_local_actor()— viaData<FederationData>contextbuild_local_actor()— same logic but withoutFederationData(for service construction)read_from_id()—Objecttrait deserialization pathfrom_json()— remote actor ingest, does 3 things: cache upsert, UUID generation, struct buildingURL construction is split between
ActorUrls::build()and manualformat!()calls ininto_json().from_json()is 76 lines performing 3 distinct tasks.private_key_pemis only populated in some paths, creating inconsistent state.Proposal
Extract actor construction into a builder/factory:
Separate
from_json()'s three responsibilities:RemoteActor::from_ap_json(json)— pure conversionactor_repo.upsert_remote_actor(actor)— cache (called by caller)DbActor::from_remote_actor(actor)— struct buildingFiles
src/actors.rs(primary —get_local_actor,build_local_actor,from_json,read_from_id)src/service/mod.rs(callsbuild_local_actor)Trade-offs
from_jsonside effects explicit instead of hiddenactivitypub_federation'sObjecttrait expectations