style: cargo fmt --all
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
use std::sync::Arc;
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
events::DomainEvent,
|
||||
ports::{EventPublisher, ShareRepository},
|
||||
value_objects::{DateTimeStamp, SystemId},
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct RevokeShareCommand {
|
||||
@@ -19,20 +19,29 @@ pub struct RevokeShareHandler {
|
||||
|
||||
impl RevokeShareHandler {
|
||||
pub fn new(share_repo: Arc<dyn ShareRepository>, event_pub: Arc<dyn EventPublisher>) -> Self {
|
||||
Self { share_repo, event_pub }
|
||||
Self {
|
||||
share_repo,
|
||||
event_pub,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn execute(&self, cmd: RevokeShareCommand) -> Result<(), DomainError> {
|
||||
self.share_repo.find_scope_by_id(&cmd.scope_id).await?
|
||||
.ok_or_else(|| DomainError::NotFound(format!("Share scope {} not found", cmd.scope_id)))?;
|
||||
self.share_repo
|
||||
.find_scope_by_id(&cmd.scope_id)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
DomainError::NotFound(format!("Share scope {} not found", cmd.scope_id))
|
||||
})?;
|
||||
|
||||
self.share_repo.delete_scope(&cmd.scope_id).await?;
|
||||
|
||||
self.event_pub.publish(DomainEvent::ShareRevoked {
|
||||
scope_id: cmd.scope_id,
|
||||
revoked_by: cmd.revoked_by,
|
||||
timestamp: DateTimeStamp::now(),
|
||||
}).await?;
|
||||
self.event_pub
|
||||
.publish(DomainEvent::ShareRevoked {
|
||||
scope_id: cmd.scope_id,
|
||||
revoked_by: cmd.revoked_by,
|
||||
timestamp: DateTimeStamp::now(),
|
||||
})
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user