summaryrefslogtreecommitdiff
path: root/src/channel/app.rs
diff options
context:
space:
mode:
authorKit La Touche <kit@transneptune.net>2024-10-25 22:16:03 -0400
committerKit La Touche <kit@transneptune.net>2024-10-25 22:16:03 -0400
commita50911a03c8955e08c77b0f3764dbda963013971 (patch)
tree9f5319191438b85b860ba06c9a203d3f129072a1 /src/channel/app.rs
parent4c49283553f4b18bb2a74de280b340a073e3253e (diff)
parentc87b5c53077c02bf21234e24bf976aa7a5f2bac8 (diff)
Merge branch 'main' into wip/mobile
Diffstat (limited to 'src/channel/app.rs')
-rw-r--r--src/channel/app.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/channel/app.rs b/src/channel/app.rs
index 7bfa0f7..8359277 100644
--- a/src/channel/app.rs
+++ b/src/channel/app.rs
@@ -4,7 +4,7 @@ use sqlx::sqlite::SqlitePool;
use super::{
repo::{LoadError, Provider as _},
- Channel, History, Id,
+ Channel, Id,
};
use crate::{
clock::DateTime,
@@ -42,12 +42,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<Option<Channel>, Error> {
+ pub async fn get(&self, channel: &Id) -> Result<Channel, Error> {
+ let not_found = || Error::NotFound(channel.clone());
+
let mut tx = self.db.begin().await?;
- let channel = tx.channels().by_id(channel).await.optional()?;
+ let channel = tx.channels().by_id(channel).await.not_found(not_found)?;
tx.commit().await?;
- Ok(channel.as_ref().and_then(History::as_snapshot))
+ channel.as_snapshot().ok_or_else(not_found)
}
pub async fn delete(&self, channel: &Id, deleted_at: &DateTime) -> Result<(), Error> {