fix(telegram): set parse_mode for streaming draft edits
This commit is contained in:
parent
9abdb7e333
commit
96d2a6fa99
@ -548,6 +548,15 @@ impl TelegramChannel {
|
||||
}
|
||||
}
|
||||
|
||||
fn build_edit_message_body(chat_id: &str, message_id: i64, text: &str) -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"chat_id": chat_id,
|
||||
"message_id": message_id,
|
||||
"text": Self::markdown_to_telegram_html(text),
|
||||
"parse_mode": "HTML",
|
||||
})
|
||||
}
|
||||
|
||||
fn extract_update_message_target(update: &serde_json::Value) -> Option<(String, i64)> {
|
||||
let message = update.get("message")?;
|
||||
let chat_id = message
|
||||
@ -2699,11 +2708,7 @@ impl Channel for TelegramChannel {
|
||||
}
|
||||
};
|
||||
|
||||
let body = serde_json::json!({
|
||||
"chat_id": chat_id,
|
||||
"message_id": message_id_parsed,
|
||||
"text": display_text,
|
||||
});
|
||||
let body = Self::build_edit_message_body(&chat_id, message_id_parsed, display_text);
|
||||
|
||||
let resp = self
|
||||
.client
|
||||
@ -2808,12 +2813,7 @@ impl Channel for TelegramChannel {
|
||||
};
|
||||
|
||||
// Try editing with HTML formatting
|
||||
let body = serde_json::json!({
|
||||
"chat_id": chat_id,
|
||||
"message_id": id,
|
||||
"text": Self::markdown_to_telegram_html(text),
|
||||
"parse_mode": "HTML",
|
||||
});
|
||||
let body = Self::build_edit_message_body(&chat_id, id, text);
|
||||
|
||||
let resp = self
|
||||
.client
|
||||
@ -3415,6 +3415,18 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn edit_message_body_uses_html_parse_mode() {
|
||||
let body = TelegramChannel::build_edit_message_body("123", 42, "**bold** and `code`");
|
||||
assert_eq!(body["chat_id"], "123");
|
||||
assert_eq!(body["message_id"], 42);
|
||||
assert_eq!(body["parse_mode"], "HTML");
|
||||
assert_eq!(
|
||||
body["text"],
|
||||
TelegramChannel::markdown_to_telegram_html("**bold** and `code`")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn telegram_markdown_to_html_escapes_quotes_in_link_href() {
|
||||
let rendered = TelegramChannel::markdown_to_telegram_html(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user