Emit warning and continue if the to be deleted user does not exist

This commit is contained in:
2025-03-18 01:35:49 +01:00
parent e858baaa3c
commit 5f746b90a8
2 changed files with 38 additions and 3 deletions

View File

@@ -43,6 +43,10 @@ pub trait ControllerEvents {
async fn user_deleted<T>(&self, obj: &T, username: &str) -> Result<(), Self::Error>
where
T: Resource<DynamicType = ()> + Sync;
async fn user_not_found<T>(&self, obj: &T, username: &str) -> Result<(), Self::Error>
where
T: Resource<DynamicType = ()> + Sync;
}
#[async_trait]
@@ -99,4 +103,21 @@ impl ControllerEvents for Recorder {
)
.await
}
async fn user_not_found<T>(&self, obj: &T, username: &str) -> Result<(), Self::Error>
where
T: Resource<DynamicType = ()> + Sync,
{
self.publish(
&Event {
type_: EventType::Warning,
reason: "UserNotFound".into(),
note: Some(format!("User '{username}' not found")),
action: "UserNotFound".into(),
secondary: None,
},
&obj.object_ref(&()),
)
.await
}
}