summaryrefslogtreecommitdiff
path: root/src/channel
diff options
context:
space:
mode:
Diffstat (limited to 'src/channel')
-rw-r--r--src/channel/app.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/channel/app.rs b/src/channel/app.rs
index cb7ad32..7c0b107 100644
--- a/src/channel/app.rs
+++ b/src/channel/app.rs
@@ -2,7 +2,7 @@ use chrono::TimeDelta;
use itertools::Itertools;
use sqlx::sqlite::SqlitePool;
-use super::{repo::Provider as _, Channel, Id};
+use super::{repo::Provider as _, Channel, History, Id};
use crate::{
clock::DateTime,
db::NotFound,
@@ -36,6 +36,16 @@ impl<'a> Channels<'a> {
Ok(channel.as_created())
}
+ // 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>, sqlx::Error> {
+ let mut tx = self.db.begin().await?;
+ let channel = tx.channels().by_id(channel).await.optional()?;
+ tx.commit().await?;
+
+ Ok(channel.iter().flat_map(History::events).collect())
+ }
+
pub async fn delete(&self, channel: &Id, deleted_at: &DateTime) -> Result<(), Error> {
let mut tx = self.db.begin().await?;