summaryrefslogtreecommitdiff
path: root/src/channel/app.rs
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/app.rs
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/app.rs')
-rw-r--r--src/channel/app.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/channel/app.rs b/src/channel/app.rs
index dc9e584..e3b169c 100644
--- a/src/channel/app.rs
+++ b/src/channel/app.rs
@@ -48,14 +48,14 @@ impl<'a> Channels<'a> {
// This function is careless with respect to time, and gets you the channel as
// it exists in the specific moment when you call it.
pub async fn get(&self, channel: &Id) -> Result<Channel, Error> {
- let not_found = || Error::NotFound(channel.clone());
- let deleted = || Error::Deleted(channel.clone());
+ let to_not_found = || Error::NotFound(channel.clone());
+ let to_deleted = || Error::Deleted(channel.clone());
let mut tx = self.db.begin().await?;
- let channel = tx.channels().by_id(channel).await.not_found(not_found)?;
+ let channel = tx.channels().by_id(channel).await.not_found(to_not_found)?;
tx.commit().await?;
- channel.as_snapshot().ok_or_else(deleted)
+ channel.as_snapshot().ok_or_else(to_deleted)
}
pub async fn delete(&self, channel: &Id, deleted_at: &DateTime) -> Result<(), DeleteError> {