diff --git a/src/channels/mod.rs b/src/channels/mod.rs index 9f5f5749f..4e23bc796 100644 --- a/src/channels/mod.rs +++ b/src/channels/mod.rs @@ -4694,10 +4694,10 @@ fn collect_configured_channels( tg.bot_token.clone(), tg.allowed_users.clone(), tg.effective_group_reply_mode().requires_mention(), + tg.ack_enabled, ) .with_group_reply_allowed_senders(tg.group_reply_allowed_sender_ids()) .with_ack_reaction(config.channels_config.ack_reaction.telegram.clone()) - .with_ack_enabled(tg.ack_enabled) .with_streaming(tg.stream_mode, tg.draft_update_interval_ms) .with_transcription(config.transcription.clone()) .with_workspace_dir(config.workspace_dir.clone()); diff --git a/src/channels/telegram.rs b/src/channels/telegram.rs index 232e7dfc0..bb752b106 100644 --- a/src/channels/telegram.rs +++ b/src/channels/telegram.rs @@ -472,7 +472,12 @@ pub struct TelegramChannel { } impl TelegramChannel { - pub fn new(bot_token: String, allowed_users: Vec, mention_only: bool) -> Self { + pub fn new( + bot_token: String, + allowed_users: Vec, + mention_only: bool, + ack_enabled: bool, + ) -> Self { let normalized_allowed = Self::normalize_allowed_users(allowed_users); let pairing = if normalized_allowed.is_empty() { let guard = PairingGuard::new(true, &[]); @@ -502,7 +507,7 @@ impl TelegramChannel { voice_transcriptions: Mutex::new(std::collections::HashMap::new()), workspace_dir: None, ack_reaction: None, - ack_enabled: true, + ack_enabled, } } @@ -3484,7 +3489,7 @@ mod tests { #[test] fn telegram_channel_name() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); assert_eq!(ch.name(), "telegram"); } @@ -3521,14 +3526,14 @@ mod tests { #[test] fn typing_handle_starts_as_none() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); let guard = ch.typing_handle.lock(); assert!(guard.is_none()); } #[tokio::test] async fn stop_typing_clears_handle() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); // Manually insert a dummy handle { @@ -3547,7 +3552,7 @@ mod tests { #[tokio::test] async fn start_typing_replaces_previous_handle() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); // Insert a dummy handle first { @@ -3566,10 +3571,10 @@ mod tests { #[test] fn supports_draft_updates_respects_stream_mode() { - let off = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let off = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); assert!(!off.supports_draft_updates()); - let partial = TelegramChannel::new("fake-token".into(), vec!["*".into()], false) + let partial = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true) .with_streaming(StreamMode::Partial, 750); assert!(partial.supports_draft_updates()); assert_eq!(partial.draft_update_interval_ms, 750); @@ -3577,7 +3582,7 @@ mod tests { #[tokio::test] async fn send_draft_returns_none_when_stream_mode_off() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); let id = ch .send_draft(&SendMessage::new("draft", "123")) .await @@ -3587,7 +3592,7 @@ mod tests { #[tokio::test] async fn update_draft_rate_limit_short_circuits_network() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false) + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true) .with_streaming(StreamMode::Partial, 60_000); ch.last_draft_edit .lock() @@ -3599,7 +3604,7 @@ mod tests { #[tokio::test] async fn update_draft_utf8_truncation_is_safe_for_multibyte_text() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false) + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true) .with_streaming(StreamMode::Partial, 0); let long_emoji_text = "😀".repeat(TELEGRAM_MAX_MESSAGE_LENGTH + 20); @@ -3613,7 +3618,7 @@ mod tests { #[tokio::test] async fn finalize_draft_invalid_message_id_falls_back_to_chunk_send() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false) + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true) .with_streaming(StreamMode::Partial, 0); let long_text = "a".repeat(TELEGRAM_MAX_MESSAGE_LENGTH + 64); @@ -4185,7 +4190,7 @@ mod tests { #[tokio::test] async fn telegram_send_document_bytes_builds_correct_form() { // This test verifies the method doesn't panic and handles bytes correctly - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); let file_bytes = b"Hello, this is a test file content".to_vec(); // The actual API call will fail (no real server), but we verify the method exists @@ -4206,7 +4211,7 @@ mod tests { #[tokio::test] async fn telegram_send_photo_bytes_builds_correct_form() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); // Minimal valid PNG header bytes let file_bytes = vec![0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]; @@ -4219,7 +4224,7 @@ mod tests { #[tokio::test] async fn telegram_send_document_by_url_builds_correct_json() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); let result = ch .send_document_by_url( @@ -4235,7 +4240,7 @@ mod tests { #[tokio::test] async fn telegram_send_photo_by_url_builds_correct_json() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); let result = ch .send_photo_by_url("123456", None, "https://example.com/image.jpg", None) @@ -4248,7 +4253,7 @@ mod tests { #[tokio::test] async fn telegram_send_document_nonexistent_file() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); let path = Path::new("/nonexistent/path/to/file.txt"); let result = ch.send_document("123456", None, path, None).await; @@ -4264,7 +4269,7 @@ mod tests { #[tokio::test] async fn telegram_send_photo_nonexistent_file() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); let path = Path::new("/nonexistent/path/to/photo.jpg"); let result = ch.send_photo("123456", None, path, None).await; @@ -4274,7 +4279,7 @@ mod tests { #[tokio::test] async fn telegram_send_video_nonexistent_file() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); let path = Path::new("/nonexistent/path/to/video.mp4"); let result = ch.send_video("123456", None, path, None).await; @@ -4284,7 +4289,7 @@ mod tests { #[tokio::test] async fn telegram_send_audio_nonexistent_file() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); let path = Path::new("/nonexistent/path/to/audio.mp3"); let result = ch.send_audio("123456", None, path, None).await; @@ -4294,7 +4299,7 @@ mod tests { #[tokio::test] async fn telegram_send_voice_nonexistent_file() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); let path = Path::new("/nonexistent/path/to/voice.ogg"); let result = ch.send_voice("123456", None, path, None).await; @@ -4382,7 +4387,7 @@ mod tests { #[tokio::test] async fn telegram_send_document_bytes_with_caption() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); let file_bytes = b"test content".to_vec(); // With caption @@ -4406,7 +4411,7 @@ mod tests { #[tokio::test] async fn telegram_send_photo_bytes_with_caption() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); let file_bytes = vec![0x89, 0x50, 0x4E, 0x47]; // With caption @@ -4432,7 +4437,7 @@ mod tests { #[tokio::test] async fn telegram_send_document_bytes_empty_file() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); let file_bytes: Vec = vec![]; let result = ch @@ -4445,7 +4450,7 @@ mod tests { #[tokio::test] async fn telegram_send_document_bytes_empty_filename() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); let file_bytes = b"content".to_vec(); let result = ch @@ -4458,7 +4463,7 @@ mod tests { #[tokio::test] async fn telegram_send_document_bytes_empty_chat_id() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false); + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true); let file_bytes = b"content".to_vec(); let result = ch @@ -5620,7 +5625,7 @@ mod tests { #[test] fn with_workspace_dir_sets_field() { - let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false) + let ch = TelegramChannel::new("fake-token".into(), vec!["*".into()], false, true) .with_workspace_dir(std::path::PathBuf::from("/tmp/test_workspace")); assert_eq!( ch.workspace_dir.as_deref(), diff --git a/src/cron/scheduler.rs b/src/cron/scheduler.rs index cfcc73f14..567651533 100644 --- a/src/cron/scheduler.rs +++ b/src/cron/scheduler.rs @@ -337,8 +337,8 @@ pub(crate) async fn deliver_announcement( tg.bot_token.clone(), tg.allowed_users.clone(), tg.mention_only, + tg.ack_enabled, ) - .with_ack_enabled(tg.ack_enabled) .with_workspace_dir(config.workspace_dir.clone()); channel.send(&SendMessage::new(output, target)).await?; }