diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-09-15 22:25:48 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-09-15 22:25:48 -0400 |
| commit | 8738cf083caaf9d8ecb1918e14712f7b09f490a5 (patch) | |
| tree | 502fc6b6c9c6dadc9aeeb5c3867de06c296c0055 /src/channel | |
| parent | ae04a5605b939709552f9ecac91f00e734813980 (diff) | |
Move channel list into the `app.channels()` namespace.
This is groundwork for a JSON-based API, after a conversation with Kit.
Diffstat (limited to 'src/channel')
| -rw-r--r-- | src/channel/app.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/channel/app.rs b/src/channel/app.rs index 5417a5e..36fa552 100644 --- a/src/channel/app.rs +++ b/src/channel/app.rs @@ -11,7 +11,7 @@ use tokio::sync::broadcast::{channel, Sender}; use tokio_stream::wrappers::BroadcastStream; use super::repo::{ - channels::{Id as ChannelId, Provider as _}, + channels::{Channel, Id as ChannelId, Provider as _}, messages::{BroadcastMessage, Provider as _}, }; use crate::{clock::DateTime, error::BoxedError, login::repo::logins::Login}; @@ -35,6 +35,14 @@ impl<'a> Channels<'a> { Ok(()) } + pub async fn all(&self) -> Result<Vec<Channel>, BoxedError> { + let mut tx = self.db.begin().await?; + let channels = tx.channels().all().await?; + tx.commit().await?; + + Ok(channels) + } + pub async fn send( &self, login: &Login, |
