fix(telegram): keep durable html unsanitized

This commit is contained in:
Ayaan Zaidi
2026-05-12 15:38:46 +05:30
parent b480b29dc7
commit f6adc78f06
3 changed files with 20 additions and 3 deletions

View File

@@ -167,6 +167,25 @@ describe("telegramOutbound", () => {
expect(result).toEqual({ channel: "telegram", messageId: "tg-silent", chatId: "12345" });
});
it("does not plain-text sanitize Telegram HTML before durable delivery", async () => {
sendMessageTelegramMock.mockResolvedValueOnce({ messageId: "tg-html", chatId: "12345" });
await telegramOutbound.sendText!({
cfg: {} as never,
to: "12345",
text: "<b>Morning</b> <code>oauth2</code>",
deps: { sendTelegram: sendMessageTelegramMock },
});
const options = callOptionsAt(
sendMessageTelegramMock,
0,
"12345",
"<b>Morning</b> <code>oauth2</code>",
);
expect(options.textMode).toBeUndefined();
});
it("forwards audioAsVoice payload media to Telegram voice sends", async () => {
sendMessageTelegramMock.mockResolvedValueOnce({ messageId: "tg-voice", chatId: "12345" });

View File

@@ -7,7 +7,6 @@ import {
presentationToInteractiveReply,
renderMessagePresentationFallbackText,
} from "openclaw/plugin-sdk/interactive-runtime";
import { sanitizeForPlainText } from "openclaw/plugin-sdk/outbound-runtime";
import type { OutboundDeliveryFormattingOptions } from "openclaw/plugin-sdk/outbound-runtime";
import {
resolveOutboundSendDep,
@@ -165,8 +164,6 @@ export function createTelegramOutboundAdapter(
chunkedTextFormatting: { parseMode: "HTML" },
extractMarkdownImages: true,
textChunkLimit: TELEGRAM_TEXT_CHUNK_LIMIT,
sanitizeText: ({ text }) => sanitizeForPlainText(text),
shouldSkipPlainTextSanitization: ({ payload }) => Boolean(payload.channelData),
shouldSuppressLocalPayloadPrompt: options.shouldSuppressLocalPayloadPrompt,
beforeDeliverPayload: options.beforeDeliverPayload,
shouldTreatDeliveredTextAsVisible: options.shouldTreatDeliveredTextAsVisible,

View File

@@ -14,6 +14,7 @@ describe("telegramPlugin outbound", () => {
expect(telegramOutbound.chunkerMode).toBe("markdown");
expect(telegramOutbound.chunkedTextFormatting).toEqual({ parseMode: "HTML" });
expect(telegramOutbound.textChunkLimit).toBe(4000);
expect(telegramOutbound.sanitizeText).toBeUndefined();
expect(telegramOutbound.pollMaxOptions).toBe(10);
});