mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 02:38:26 +00:00
Revert "fix(whatsapp): allow per-message link preview override\n\nWhatsApp messages default to enabling link previews for URLs. This adds\nsupport for overriding this behavior per-message via the \nparameter (e.g. from tool options), consistent with Telegram.\n\nFix: Updated internal WhatsApp Web API layers to pass option\ndown to Baileys ."
This reverts commit 1bef2fc68b.
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
import type {
|
||||
AnyMessageContent,
|
||||
MiscMessageGenerationOptions,
|
||||
WAPresence,
|
||||
} from "@whiskeysockets/baileys";
|
||||
import type { AnyMessageContent, WAPresence } from "@whiskeysockets/baileys";
|
||||
import type { ActiveWebSendOptions } from "../active-listener.js";
|
||||
import { recordChannelActivity } from "../../infra/channel-activity.js";
|
||||
import { toWhatsappJid } from "../../utils.js";
|
||||
import type { ActiveWebSendOptions } from "../active-listener.js";
|
||||
|
||||
function recordWhatsAppOutbound(accountId: string) {
|
||||
recordChannelActivity({
|
||||
@@ -23,11 +19,7 @@ function resolveOutboundMessageId(result: unknown): string {
|
||||
|
||||
export function createWebSendApi(params: {
|
||||
sock: {
|
||||
sendMessage: (
|
||||
jid: string,
|
||||
content: AnyMessageContent,
|
||||
options?: MiscMessageGenerationOptions,
|
||||
) => Promise<unknown>;
|
||||
sendMessage: (jid: string, content: AnyMessageContent) => Promise<unknown>;
|
||||
sendPresenceUpdate: (presence: WAPresence, jid?: string) => Promise<unknown>;
|
||||
};
|
||||
defaultAccountId: string;
|
||||
@@ -71,14 +63,7 @@ export function createWebSendApi(params: {
|
||||
} else {
|
||||
payload = { text };
|
||||
}
|
||||
let result;
|
||||
if (sendOptions?.linkPreview === false) {
|
||||
// Baileys types have changed across releases; keep backward-compatible runtime behavior.
|
||||
const miscOptions = { linkPreview: null } as unknown as MiscMessageGenerationOptions;
|
||||
result = await params.sock.sendMessage(jid, payload, miscOptions);
|
||||
} else {
|
||||
result = await params.sock.sendMessage(jid, payload);
|
||||
}
|
||||
const result = await params.sock.sendMessage(jid, payload);
|
||||
const accountId = sendOptions?.accountId ?? params.defaultAccountId;
|
||||
recordWhatsAppOutbound(accountId);
|
||||
const messageId = resolveOutboundMessageId(result);
|
||||
|
||||
Reference in New Issue
Block a user