From 54764935c22b289e09bfc2b577e0e15dcd7af619 Mon Sep 17 00:00:00 2001 From: lew Date: Fri, 10 Apr 2026 02:17:05 +0100 Subject: [PATCH] refactor: extend channel to carry voice note bytes --- src/main.rs | 2 +- src/telegram.rs | 4 ++-- src/web.rs | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 969ffe7..36956c4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,7 +18,7 @@ async fn main() { std::fs::create_dir_all(&entries_dir).ok(); - let (tx, rx) = tokio::sync::mpsc::channel::<(entries::Entry, Option>)>(32); + let (tx, rx) = tokio::sync::mpsc::channel::<(entries::Entry, Option>, Option>)>(32); // Spawn telegram tasks if configured match (&config.telegram_bot_token, config.telegram_chat_id) { diff --git a/src/telegram.rs b/src/telegram.rs index 2001824..ad4dd9d 100644 --- a/src/telegram.rs +++ b/src/telegram.rs @@ -18,8 +18,8 @@ async fn notify(bot: &Bot, chat_id: ChatId, entry: &Entry) { } /// Listen for new entries on the channel and send Telegram notifications. -pub async fn notification_task(bot: Bot, chat_id: ChatId, mut rx: Receiver<(Entry, Option>)>) { - while let Some((entry, drawing_bytes)) = rx.recv().await { +pub async fn notification_task(bot: Bot, chat_id: ChatId, mut rx: Receiver<(Entry, Option>, Option>)>) { + while let Some((entry, drawing_bytes, _voice_bytes)) = rx.recv().await { notify(&bot, chat_id, &entry).await; if let Some(bytes) = drawing_bytes { if let Err(e) = bot.send_photo( diff --git a/src/web.rs b/src/web.rs index f673b82..ed2ef9c 100644 --- a/src/web.rs +++ b/src/web.rs @@ -18,7 +18,7 @@ use crate::render::{self, DEFAULT_TEMPLATE, render_error_page, render_success_pa pub struct AppState { pub config: Config, - pub tx: tokio::sync::mpsc::Sender<(Entry, Option>)>, + pub tx: tokio::sync::mpsc::Sender<(Entry, Option>, Option>)>, } #[derive(Deserialize)] @@ -228,7 +228,7 @@ async fn submit( } // Notify telegram task - let _ = state.tx.send((entry, drawing_bytes)).await; + let _ = state.tx.send((entry, drawing_bytes, None)).await; Html(render_success_page(&state.config)) } @@ -283,7 +283,7 @@ mod tests { } } - fn test_app(config: Config) -> (Router, tokio::sync::mpsc::Receiver<(Entry, Option>)>) { + fn test_app(config: Config) -> (Router, tokio::sync::mpsc::Receiver<(Entry, Option>, Option>)>) { let (tx, rx) = tokio::sync::mpsc::channel(32); let state = Arc::new(AppState { config, tx }); (router(state), rx)