summaryrefslogtreecommitdiff
path: root/src/message/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'src/message/handlers')
-rw-r--r--src/message/handlers/delete/mod.rs11
-rw-r--r--src/message/handlers/delete/test.rs8
2 files changed, 12 insertions, 7 deletions
diff --git a/src/message/handlers/delete/mod.rs b/src/message/handlers/delete/mod.rs
index 5eac4eb..606f502 100644
--- a/src/message/handlers/delete/mod.rs
+++ b/src/message/handlers/delete/mod.rs
@@ -22,7 +22,7 @@ pub async fn handler(
identity: Identity,
) -> Result<Response, Error> {
app.messages()
- .delete(&identity.user, &message, &deleted_at)
+ .delete(&identity.login, &message, &deleted_at)
.await?;
Ok(Response { id: message })
@@ -48,8 +48,13 @@ impl IntoResponse for Error {
let Self(error) = self;
match error {
DeleteError::NotSender(_) => (StatusCode::FORBIDDEN, error.to_string()).into_response(),
- DeleteError::NotFound(_) | DeleteError::Deleted(_) => NotFound(error).into_response(),
- DeleteError::Database(_) => Internal::from(error).into_response(),
+ DeleteError::MessageNotFound(_) | DeleteError::Deleted(_) => {
+ NotFound(error).into_response()
+ }
+ DeleteError::UserNotFound(_)
+ | DeleteError::UserDeleted(_)
+ | DeleteError::Database(_)
+ | DeleteError::Name(_) => Internal::from(error).into_response(),
}
}
}
diff --git a/src/message/handlers/delete/test.rs b/src/message/handlers/delete/test.rs
index 371c7bf..d0e1794 100644
--- a/src/message/handlers/delete/test.rs
+++ b/src/message/handlers/delete/test.rs
@@ -11,7 +11,7 @@ pub async fn delete_message() {
let sender = fixtures::identity::create(&app, &fixtures::now()).await;
let conversation = fixtures::conversation::create(&app, &fixtures::now()).await;
let message =
- fixtures::message::send(&app, &conversation, &sender.user, &fixtures::now()).await;
+ fixtures::message::send(&app, &conversation, &sender.login, &fixtures::now()).await;
// Send the request
@@ -62,7 +62,7 @@ pub async fn delete_invalid_message_id() {
// Verify the response
- assert!(matches!(error, app::DeleteError::NotFound(id) if id == message));
+ assert!(matches!(error, app::DeleteError::MessageNotFound(id) if id == message));
}
#[tokio::test]
@@ -160,7 +160,7 @@ pub async fn delete_purged() {
// Verify the response
- assert!(matches!(error, app::DeleteError::NotFound(id) if id == message.id));
+ assert!(matches!(error, app::DeleteError::MessageNotFound(id) if id == message.id));
}
#[tokio::test]
@@ -187,6 +187,6 @@ pub async fn delete_not_sender() {
// Verify the response
assert!(
- matches!(error, app::DeleteError::NotSender(error_sender) if deleter.user == error_sender)
+ matches!(error, app::DeleteError::NotSender(error_sender) if deleter.login.id == error_sender)
);
}