fix: FollowTarget enum — actor_url no longer lies about holding a handle

FollowCommand.target is now FollowTarget (Identity|Handle) instead of
SocialIdentity. actor_url field always holds a URL; handles go through
FollowTarget::Handle. Adapter resolves handles explicitly. Type system
prevents misuse in future commands.
This commit is contained in:
2026-07-10 16:18:57 +02:00
parent 2484f1e603
commit d60c47199c
18 changed files with 95 additions and 45 deletions

View File

@@ -1,5 +1,5 @@
use super::*;
use crate::value_objects::{SocialIdentity, UserId};
use crate::value_objects::{FollowTarget, SocialIdentity, UserId};
#[test]
fn follow_accepted_matches() {
@@ -22,17 +22,33 @@ fn follow_accepted_matches() {
}
#[test]
fn follow_requested_local() {
fn follow_requested_with_identity() {
let follower = UserId::from_uuid(uuid::Uuid::new_v4());
let target = UserId::from_uuid(uuid::Uuid::new_v4());
let event = DomainEvent::FollowRequested {
follower: follower.clone(),
target: SocialIdentity::Local(target.clone()),
target: FollowTarget::Identity(SocialIdentity::Local(target.clone())),
};
assert!(matches!(
event,
DomainEvent::FollowRequested {
target: SocialIdentity::Local(_),
target: FollowTarget::Identity(SocialIdentity::Local(_)),
..
}
));
}
#[test]
fn follow_requested_with_handle() {
let follower = UserId::from_uuid(uuid::Uuid::new_v4());
let event = DomainEvent::FollowRequested {
follower: follower.clone(),
target: FollowTarget::Handle("@alice@remote.example".into()),
};
assert!(matches!(
event,
DomainEvent::FollowRequested {
target: FollowTarget::Handle(_),
..
}
));