diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-10-09 23:46:16 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-10-10 19:32:49 -0400 |
| commit | d17ce92f815fa145fa56307a7e9b3993e0f4270d (patch) | |
| tree | a23ba5a37984397607386a5c1e30f6619d62bace /src/channel/app.rs | |
| parent | 03f8d9ad603a4e523a0e2a0e60ad62c8725f0875 (diff) | |
Return an instance of the client when opening a channel URL directly.
Diffstat (limited to 'src/channel/app.rs')
| -rw-r--r-- | src/channel/app.rs | 12 |
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?; |
