From 8738cf083caaf9d8ecb1918e14712f7b09f490a5 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Sun, 15 Sep 2024 22:25:48 -0400 Subject: Move channel list into the `app.channels()` namespace. This is groundwork for a JSON-based API, after a conversation with Kit. --- src/channel/app.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/channel/app.rs') 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, 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, -- cgit v1.2.3