fix(whatsapp): convert Markdown bold/strikethrough to WhatsApp formatting (#14285)
* fix(whatsapp): convert Markdown bold/strikethrough to WhatsApp formatting * refactor: Move `escapeRegExp` utility function to `utils.js`. --------- Co-authored-by: Luna AI <luna@coredirection.ai>
This commit is contained in:
@@ -4,6 +4,7 @@ import type { WebInboundMsg } from "./types.js";
|
||||
import { chunkMarkdownTextWithMode, type ChunkMode } from "../../auto-reply/chunk.js";
|
||||
import { logVerbose, shouldLogVerbose } from "../../globals.js";
|
||||
import { convertMarkdownTables } from "../../markdown/tables.js";
|
||||
import { markdownToWhatsApp } from "../../markdown/whatsapp.js";
|
||||
import { sleep } from "../../utils.js";
|
||||
import { loadWebMedia } from "../media.js";
|
||||
import { newConnectionId } from "../reconnect.js";
|
||||
@@ -29,7 +30,9 @@ export async function deliverWebReply(params: {
|
||||
const replyStarted = Date.now();
|
||||
const tableMode = params.tableMode ?? "code";
|
||||
const chunkMode = params.chunkMode ?? "length";
|
||||
const convertedText = convertMarkdownTables(replyResult.text || "", tableMode);
|
||||
const convertedText = markdownToWhatsApp(
|
||||
convertMarkdownTables(replyResult.text || "", tableMode),
|
||||
);
|
||||
const textChunks = chunkMarkdownTextWithMode(convertedText, textLimit, chunkMode);
|
||||
const mediaList = replyResult.mediaUrls?.length
|
||||
? replyResult.mediaUrls
|
||||
|
||||
@@ -4,6 +4,7 @@ import { resolveMarkdownTableMode } from "../config/markdown-tables.js";
|
||||
import { getChildLogger } from "../logging/logger.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
import { convertMarkdownTables } from "../markdown/tables.js";
|
||||
import { markdownToWhatsApp } from "../markdown/whatsapp.js";
|
||||
import { normalizePollInput, type PollInput } from "../polls.js";
|
||||
import { toWhatsappJid } from "../utils.js";
|
||||
import { type ActiveWebSendOptions, requireActiveWebListener } from "./active-listener.js";
|
||||
@@ -34,6 +35,7 @@ export async function sendMessageWhatsApp(
|
||||
accountId: resolvedAccountId ?? options.accountId,
|
||||
});
|
||||
text = convertMarkdownTables(text ?? "", tableMode);
|
||||
text = markdownToWhatsApp(text);
|
||||
const logger = getChildLogger({
|
||||
module: "web-outbound",
|
||||
correlationId,
|
||||
|
||||
Reference in New Issue
Block a user