mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 21:14:46 +00:00
fix(telegram): keep durable html unsanitized
This commit is contained in:
@@ -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" });
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user