@wednesdayai/whatsapp 0.4.12-dev.726 → 0.4.12-dev.728
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +27 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -122,7 +122,7 @@ async function sendMessageWhatsApp(to, body, options) {
|
|
|
122
122
|
...documentFileName ? { fileName: documentFileName } : {},
|
|
123
123
|
accountId
|
|
124
124
|
} : void 0;
|
|
125
|
-
const messageId = (sendOptions ? await active.sendMessage(to, text, mediaBuffer, mediaType, sendOptions) : await active.sendMessage(to, text, mediaBuffer, mediaType))?.messageId ?? "
|
|
125
|
+
const messageId = (sendOptions ? await active.sendMessage(to, text, mediaBuffer, mediaType, sendOptions) : await active.sendMessage(to, text, mediaBuffer, mediaType))?.messageId ?? "";
|
|
126
126
|
logger.info({
|
|
127
127
|
jid: redactedJid,
|
|
128
128
|
messageId,
|
|
@@ -192,7 +192,7 @@ async function sendPollWhatsApp(to, poll, options) {
|
|
|
192
192
|
optionCount: normalized.options.length,
|
|
193
193
|
maxSelections: normalized.maxSelections
|
|
194
194
|
}, "sending poll");
|
|
195
|
-
const messageId = (await active.sendPoll(to, normalized))?.messageId ?? "
|
|
195
|
+
const messageId = (await active.sendPoll(to, normalized))?.messageId ?? "";
|
|
196
196
|
logger.info({
|
|
197
197
|
jid: redactIdentifier(jid),
|
|
198
198
|
messageId,
|
|
@@ -1385,10 +1385,10 @@ async function monitorWebInbox(options) {
|
|
|
1385
1385
|
}
|
|
1386
1386
|
};
|
|
1387
1387
|
const reply = async (text) => {
|
|
1388
|
-
await sock.sendMessage(chatJid, { text });
|
|
1388
|
+
return (await sock.sendMessage(chatJid, { text }))?.key?.id ?? void 0;
|
|
1389
1389
|
};
|
|
1390
1390
|
const sendMedia = async (payload) => {
|
|
1391
|
-
await sock.sendMessage(chatJid, payload);
|
|
1391
|
+
return (await sock.sendMessage(chatJid, payload))?.key?.id ?? void 0;
|
|
1392
1392
|
};
|
|
1393
1393
|
const timestamp = inbound.messageTimestampMs;
|
|
1394
1394
|
const mentionedJids = extractMentionedJids(messageUtils, msg.message);
|
|
@@ -1674,7 +1674,8 @@ async function maybeBroadcastMessage(params) {
|
|
|
1674
1674
|
id: params.peerId
|
|
1675
1675
|
},
|
|
1676
1676
|
dmScope: params.cfg.session?.dmScope,
|
|
1677
|
-
identityLinks: params.cfg.session?.identityLinks
|
|
1677
|
+
identityLinks: params.cfg.session?.identityLinks,
|
|
1678
|
+
peerIdOrigin: "sender"
|
|
1678
1679
|
}),
|
|
1679
1680
|
mainSessionKey: buildAgentMainSessionKey({
|
|
1680
1681
|
agentId: normalizedAgentId,
|
|
@@ -2037,12 +2038,16 @@ async function deliverWebReply(params) {
|
|
|
2037
2038
|
throw lastErr;
|
|
2038
2039
|
};
|
|
2039
2040
|
let sentAny = false;
|
|
2041
|
+
let lastSentId;
|
|
2042
|
+
const sentId = (id) => {
|
|
2043
|
+
if (id) lastSentId = id;
|
|
2044
|
+
};
|
|
2040
2045
|
if (effectiveMediaList.length === 0 && textChunks.length) {
|
|
2041
2046
|
try {
|
|
2042
2047
|
const totalChunks = textChunks.length;
|
|
2043
2048
|
for (const [index, chunk] of textChunks.entries()) {
|
|
2044
2049
|
const chunkStarted = Date.now();
|
|
2045
|
-
await sendWithRetry(() => msg.reply(chunk), "text");
|
|
2050
|
+
sentId(await sendWithRetry(() => msg.reply(chunk), "text"));
|
|
2046
2051
|
sentAny = true;
|
|
2047
2052
|
if (!skipLog) {
|
|
2048
2053
|
const durationMs = Date.now() - chunkStarted;
|
|
@@ -2063,7 +2068,8 @@ async function deliverWebReply(params) {
|
|
|
2063
2068
|
} finally {
|
|
2064
2069
|
if (sentAny) emitMessageSent({
|
|
2065
2070
|
success: true,
|
|
2066
|
-
content: hookResult.payloadSummary.text
|
|
2071
|
+
content: hookResult.payloadSummary.text,
|
|
2072
|
+
...lastSentId ? { messageId: lastSentId } : {}
|
|
2067
2073
|
});
|
|
2068
2074
|
}
|
|
2069
2075
|
return;
|
|
@@ -2080,33 +2086,33 @@ async function deliverWebReply(params) {
|
|
|
2080
2086
|
logVerbose(`Web auto-reply media size: ${(media.buffer.length / (1024 * 1024)).toFixed(2)}MB`);
|
|
2081
2087
|
logVerbose(`Web auto-reply media source: ${mediaUrl} (kind ${media.kind})`);
|
|
2082
2088
|
}
|
|
2083
|
-
if (media.kind === "image") await sendWithRetry(() => msg.sendMedia({
|
|
2089
|
+
if (media.kind === "image") sentId(await sendWithRetry(() => msg.sendMedia({
|
|
2084
2090
|
image: media.buffer,
|
|
2085
2091
|
caption,
|
|
2086
2092
|
mimetype: media.contentType
|
|
2087
|
-
}), "media:image");
|
|
2093
|
+
}), "media:image"));
|
|
2088
2094
|
else if (media.kind === "audio") {
|
|
2089
|
-
await sendWithRetry(() => msg.sendMedia({
|
|
2095
|
+
sentId(await sendWithRetry(() => msg.sendMedia({
|
|
2090
2096
|
audio: media.buffer,
|
|
2091
2097
|
ptt: true,
|
|
2092
2098
|
mimetype: media.contentType
|
|
2093
|
-
}), "media:audio");
|
|
2099
|
+
}), "media:audio"));
|
|
2094
2100
|
sentAny = true;
|
|
2095
|
-
if (caption) await sendWithRetry(() => msg.reply(caption), "text");
|
|
2096
|
-
} else if (media.kind === "video") await sendWithRetry(() => msg.sendMedia({
|
|
2101
|
+
if (caption) sentId(await sendWithRetry(() => msg.reply(caption), "text"));
|
|
2102
|
+
} else if (media.kind === "video") sentId(await sendWithRetry(() => msg.sendMedia({
|
|
2097
2103
|
video: media.buffer,
|
|
2098
2104
|
caption,
|
|
2099
2105
|
mimetype: media.contentType
|
|
2100
|
-
}), "media:video");
|
|
2106
|
+
}), "media:video"));
|
|
2101
2107
|
else {
|
|
2102
2108
|
const fileName = media.fileName ?? mediaUrl.split("/").pop() ?? "file";
|
|
2103
2109
|
const mimetype = media.contentType ?? "application/octet-stream";
|
|
2104
|
-
await sendWithRetry(() => msg.sendMedia({
|
|
2110
|
+
sentId(await sendWithRetry(() => msg.sendMedia({
|
|
2105
2111
|
document: media.buffer,
|
|
2106
2112
|
fileName,
|
|
2107
2113
|
caption,
|
|
2108
2114
|
mimetype
|
|
2109
|
-
}), "media:document");
|
|
2115
|
+
}), "media:document"));
|
|
2110
2116
|
}
|
|
2111
2117
|
sentAny = true;
|
|
2112
2118
|
getOutboundLog$1().info(`Sent media reply to ${msg.from} (${(media.buffer.length / (1024 * 1024)).toFixed(2)}MB)`);
|
|
@@ -2133,7 +2139,7 @@ async function deliverWebReply(params) {
|
|
|
2133
2139
|
if (fallbackText) {
|
|
2134
2140
|
getOutboundLog$1().warn(`Media skipped; sent text-only to ${msg.from}`);
|
|
2135
2141
|
try {
|
|
2136
|
-
await msg.reply(fallbackText);
|
|
2142
|
+
sentId(await msg.reply(fallbackText));
|
|
2137
2143
|
sentAny = true;
|
|
2138
2144
|
} catch (fallbackErr) {
|
|
2139
2145
|
getOutboundLog$1().error(`Failed sending fallback text to ${msg.from}: ${formatError(fallbackErr)}`);
|
|
@@ -2144,13 +2150,14 @@ async function deliverWebReply(params) {
|
|
|
2144
2150
|
}
|
|
2145
2151
|
try {
|
|
2146
2152
|
for (const chunk of remainingText) {
|
|
2147
|
-
await msg.reply(chunk);
|
|
2153
|
+
sentId(await msg.reply(chunk));
|
|
2148
2154
|
sentAny = true;
|
|
2149
2155
|
}
|
|
2150
2156
|
} finally {
|
|
2151
2157
|
if (sentAny) emitMessageSent({
|
|
2152
2158
|
success: true,
|
|
2153
|
-
content: hookResult.payloadSummary.text
|
|
2159
|
+
content: hookResult.payloadSummary.text,
|
|
2160
|
+
...lastSentId ? { messageId: lastSentId } : {}
|
|
2154
2161
|
});
|
|
2155
2162
|
}
|
|
2156
2163
|
}
|
|
@@ -3355,8 +3362,7 @@ const whatsappPlugin = {
|
|
|
3355
3362
|
...meta,
|
|
3356
3363
|
showConfigured: false,
|
|
3357
3364
|
quickstartAllowFrom: true,
|
|
3358
|
-
forceAccountBinding: true
|
|
3359
|
-
preferSessionLookupForAnnounceTarget: true
|
|
3365
|
+
forceAccountBinding: true
|
|
3360
3366
|
},
|
|
3361
3367
|
onboarding: whatsappOnboardingAdapter,
|
|
3362
3368
|
agentTools: () => [createWhatsAppLoginTool()],
|