fmt
This commit is contained in:
@@ -242,5 +242,4 @@ impl SocialQuery for CompositeSocialAdapter {
|
|||||||
let following = self.get_following(follower).await?;
|
let following = self.get_following(follower).await?;
|
||||||
Ok(following.iter().any(|a| a.identity == *target))
|
Ok(following.iter().any(|a| a.identity == *target))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,10 +67,7 @@ struct FakeSocialWithFollowing(Vec<SocialActor>);
|
|||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl domain::ports::SocialQuery for FakeSocialWithFollowing {
|
impl domain::ports::SocialQuery for FakeSocialWithFollowing {
|
||||||
async fn get_following(
|
async fn get_following(&self, _: &UserId) -> Result<Vec<SocialActor>, DomainError> {
|
||||||
&self,
|
|
||||||
_: &UserId,
|
|
||||||
) -> Result<Vec<SocialActor>, DomainError> {
|
|
||||||
Ok(self.0.clone())
|
Ok(self.0.clone())
|
||||||
}
|
}
|
||||||
async fn get_followers(&self, _: &UserId) -> Result<Vec<SocialActor>, DomainError> {
|
async fn get_followers(&self, _: &UserId) -> Result<Vec<SocialActor>, DomainError> {
|
||||||
|
|||||||
@@ -10,10 +10,7 @@ use super::{
|
|||||||
queries::SocialQry,
|
queries::SocialQry,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub async fn execute_command(
|
pub async fn execute_command(deps: &SocialCommandDeps, cmd: SocialCmd) -> Result<(), DomainError> {
|
||||||
deps: &SocialCommandDeps,
|
|
||||||
cmd: SocialCmd,
|
|
||||||
) -> Result<(), DomainError> {
|
|
||||||
let event = match cmd {
|
let event = match cmd {
|
||||||
SocialCmd::Follow {
|
SocialCmd::Follow {
|
||||||
follower_id,
|
follower_id,
|
||||||
@@ -58,18 +55,12 @@ pub async fn execute_command(
|
|||||||
.await?;
|
.await?;
|
||||||
DomainEvent::FollowerRemoved { owner, follower }
|
DomainEvent::FollowerRemoved { owner, follower }
|
||||||
}
|
}
|
||||||
SocialCmd::Block {
|
SocialCmd::Block { blocker_id, target } => {
|
||||||
blocker_id,
|
|
||||||
target,
|
|
||||||
} => {
|
|
||||||
let blocker = UserId::from_uuid(blocker_id);
|
let blocker = UserId::from_uuid(blocker_id);
|
||||||
deps.social_command.block(&blocker, &target).await?;
|
deps.social_command.block(&blocker, &target).await?;
|
||||||
DomainEvent::ActorBlocked { blocker, target }
|
DomainEvent::ActorBlocked { blocker, target }
|
||||||
}
|
}
|
||||||
SocialCmd::Unblock {
|
SocialCmd::Unblock { blocker_id, target } => {
|
||||||
blocker_id,
|
|
||||||
target,
|
|
||||||
} => {
|
|
||||||
let blocker = UserId::from_uuid(blocker_id);
|
let blocker = UserId::from_uuid(blocker_id);
|
||||||
deps.social_command.unblock(&blocker, &target).await?;
|
deps.social_command.unblock(&blocker, &target).await?;
|
||||||
DomainEvent::ActorUnblocked { blocker, target }
|
DomainEvent::ActorUnblocked { blocker, target }
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ async fn follow_emits_follow_requested_event() {
|
|||||||
&deps,
|
&deps,
|
||||||
SocialCmd::Follow {
|
SocialCmd::Follow {
|
||||||
follower_id: Uuid::new_v4(),
|
follower_id: Uuid::new_v4(),
|
||||||
target: FollowTarget::Identity(SocialIdentity::Local(UserId::from_uuid(
|
target: FollowTarget::Identity(SocialIdentity::Local(
|
||||||
Uuid::new_v4(),
|
UserId::from_uuid(Uuid::new_v4()),
|
||||||
))),
|
)),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -41,7 +41,11 @@ pub struct NoopSocialCommand;
|
|||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl super::SocialCommand for NoopSocialCommand {
|
impl super::SocialCommand for NoopSocialCommand {
|
||||||
async fn follow(&self, _: &UserId, _: &crate::value_objects::FollowTarget) -> Result<(), DomainError> {
|
async fn follow(
|
||||||
|
&self,
|
||||||
|
_: &UserId,
|
||||||
|
_: &crate::value_objects::FollowTarget,
|
||||||
|
) -> Result<(), DomainError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
async fn unfollow(&self, _: &UserId, _: &SocialIdentity) -> Result<(), DomainError> {
|
async fn unfollow(&self, _: &UserId, _: &SocialIdentity) -> Result<(), DomainError> {
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ pub trait SocialQuery: Send + Sync {
|
|||||||
follower: &UserId,
|
follower: &UserId,
|
||||||
target: &SocialIdentity,
|
target: &SocialIdentity,
|
||||||
) -> Result<bool, DomainError>;
|
) -> Result<bool, DomainError>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|||||||
@@ -1105,5 +1105,4 @@ impl SocialQuery for InMemorySocialRepository {
|
|||||||
*f == follower.value() && t == target && *state == FollowState::Accepted
|
*f == follower.value() && t == target && *state == FollowState::Accepted
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user