fix(channels): add reply_to field to ChannelMessage for correct reply routing

ChannelMessage.sender was used both for display (username) and as the
reply target in Channel::send(). For Telegram, sender is the username
(e.g. "unknown") while send() requires the numeric chat_id, causing
"Bad Request: chat not found" errors.

Add a dedicated reply_to field to ChannelMessage that stores the
channel-specific reply address (Telegram chat_id, Discord channel_id,
Slack channel, etc.). Update all channel implementations and dispatch
code to use reply_to for send/start_typing/stop_typing calls.

This also fixes the same latent bug in Discord and Slack channels where
sender (user ID) was incorrectly passed as the reply target.
This commit is contained in:
chenmi 2026-02-17 09:13:30 +08:00 committed by Chummy
parent e21285f453
commit 18952f9a2b
15 changed files with 42 additions and 10 deletions

View file

@ -5,6 +5,9 @@ use async_trait::async_trait;
pub struct ChannelMessage {
pub id: String,
pub sender: String,
/// Channel-specific reply address (e.g. Telegram chat_id, Discord channel_id, Slack channel).
/// Used by `Channel::send()` to route the reply to the correct destination.
pub reply_to: String,
pub content: String,
pub channel: String,
pub timestamp: u64,
@ -62,6 +65,7 @@ mod tests {
tx.send(ChannelMessage {
id: "1".into(),
sender: "tester".into(),
reply_to: "tester".into(),
content: "hello".into(),
channel: "dummy".into(),
timestamp: 123,
@ -76,6 +80,7 @@ mod tests {
let message = ChannelMessage {
id: "42".into(),
sender: "alice".into(),
reply_to: "alice".into(),
content: "ping".into(),
channel: "dummy".into(),
timestamp: 999,