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:
parent
e21285f453
commit
18952f9a2b
15 changed files with 42 additions and 10 deletions
|
|
@ -709,7 +709,7 @@ async fn handle_whatsapp_message(
|
|||
{
|
||||
Ok(response) => {
|
||||
// Send reply via WhatsApp
|
||||
if let Err(e) = wa.send(&response, &msg.sender).await {
|
||||
if let Err(e) = wa.send(&response, &msg.reply_to).await {
|
||||
tracing::error!("Failed to send WhatsApp reply: {e}");
|
||||
}
|
||||
}
|
||||
|
|
@ -718,7 +718,7 @@ async fn handle_whatsapp_message(
|
|||
let _ = wa
|
||||
.send(
|
||||
"Sorry, I couldn't process your message right now.",
|
||||
&msg.sender,
|
||||
&msg.reply_to,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
|
@ -860,6 +860,7 @@ mod tests {
|
|||
let msg = ChannelMessage {
|
||||
id: "wamid-123".into(),
|
||||
sender: "+1234567890".into(),
|
||||
reply_to: "+1234567890".into(),
|
||||
content: "hello".into(),
|
||||
channel: "whatsapp".into(),
|
||||
timestamp: 1,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue