summaryrefslogtreecommitdiff
path: root/src/channel/handlers
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2025-07-01 01:42:38 -0400
committerOwen Jacobson <owen@grimoire.ca>2025-07-03 21:47:41 -0400
commitb4db819ef8daa583a165aed01eb3d70d98e37fc8 (patch)
tree81f18139d11f6f197f90958a7a28a83aab6c14cf /src/channel/handlers
parentb3ce81945621e9026e687b590e7aa541008575ac (diff)
Prevent sending messages to deleted channels.
I've opted to make it clear in the error message which scenario - deleted vs. non-existant - a channel falls into. This isn't particularly consistent with the rest of the API, so we might need to review this decision later, but it's at least relatively harmless if it's mistaken. (Formally, they're both 404s, so clients that go by error code won't notice.)
Diffstat (limited to 'src/channel/handlers')
-rw-r--r--src/channel/handlers/send/mod.rs4
-rw-r--r--src/channel/handlers/send/test.rs2
2 files changed, 4 insertions, 2 deletions
diff --git a/src/channel/handlers/send/mod.rs b/src/channel/handlers/send/mod.rs
index aa241e2..bde39e5 100644
--- a/src/channel/handlers/send/mod.rs
+++ b/src/channel/handlers/send/mod.rs
@@ -54,7 +54,9 @@ impl IntoResponse for Error {
fn into_response(self) -> response::Response {
let Self(error) = self;
match error {
- SendError::ChannelNotFound(_) => NotFound(error).into_response(),
+ SendError::ChannelNotFound(_) | SendError::ChannelDeleted(_) => {
+ NotFound(error).into_response()
+ }
SendError::Name(_) | SendError::Database(_) => Internal::from(error).into_response(),
}
}
diff --git a/src/channel/handlers/send/test.rs b/src/channel/handlers/send/test.rs
index d77e07d..70d45eb 100644
--- a/src/channel/handlers/send/test.rs
+++ b/src/channel/handlers/send/test.rs
@@ -125,6 +125,6 @@ async fn deleted_channel() {
assert!(matches!(
error,
- SendError::ChannelNotFound(error_channel) if channel.id == error_channel
+ SendError::ChannelDeleted(error_channel) if channel.id == error_channel
));
}