@openclaw/whatsapp 2026.5.2-beta.2 → 2026.5.3-beta.1
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/access-control-BQ3tCkH8.js +288 -0
- package/dist/account-config-CNQ33oav.js +47 -0
- package/dist/account-ids-DG18xddX.js +5 -0
- package/dist/accounts-BDqgpFEB.js +116 -0
- package/dist/action-runtime-DTGNgG-i.js +74 -0
- package/dist/action-runtime-api.js +2 -0
- package/dist/action-runtime.runtime.js +2 -0
- package/dist/active-listener-N7GFKsuN.js +11 -0
- package/dist/agent-tools-login-DpRxLNRB.js +89 -0
- package/dist/api.js +148 -0
- package/dist/audio-preflight.runtime-Bcdsl_ri.js +7 -0
- package/dist/auth-presence.js +32 -0
- package/dist/auth-store-BjCb50Ry.js +381 -0
- package/dist/channel-DQ-5Xoj9.js +542 -0
- package/dist/channel-config-api.js +2 -0
- package/dist/channel-plugin-api.js +2 -0
- package/dist/channel-react-action-Df20qAy9.js +42 -0
- package/dist/channel.runtime-DKXRnA8x.js +55 -0
- package/dist/channel.setup-DOHR2BGp.js +20 -0
- package/dist/command-policy-O8sRnqUV.js +8 -0
- package/dist/config-schema-Dmo66Ubb.js +27 -0
- package/dist/connection-controller-BiHAsTM8.js +596 -0
- package/dist/connection-controller-registry-D_iIGz5m.js +22 -0
- package/dist/constants-DLGCIbfl.js +4 -0
- package/dist/constants.js +2 -0
- package/dist/contract-api.js +19 -0
- package/dist/creds-files-_2V8jzQa.js +19 -0
- package/dist/directory-config-DVs4ffXu.js +37 -0
- package/dist/directory-contract-api.js +2 -0
- package/dist/doctor-A9tXm9Om.js +48 -0
- package/dist/doctor-contract-api.js +10 -0
- package/dist/group-session-contract-B8QBn0I2.js +15 -0
- package/dist/identity-QHAlV7Fu.js +75 -0
- package/dist/index.js +18 -0
- package/dist/legacy-session-surface-api.js +8 -0
- package/dist/legacy-state-migrations-api.js +2 -0
- package/dist/light-runtime-api.js +5 -0
- package/dist/login-DymdrKca.js +52 -0
- package/dist/login-qr-DIS0Iv-7.js +378 -0
- package/dist/login-qr-api.js +2 -0
- package/dist/login-qr-runtime.js +16 -0
- package/dist/monitor-C4Fhg_lD.js +3349 -0
- package/dist/normalize-CWYiGkXw.js +2 -0
- package/dist/normalize-target-BPVHNsM5.js +74 -0
- package/dist/outbound-adapter-BssVnZdz.js +29 -0
- package/dist/outbound-base-Bq1UYEK5.js +119 -0
- package/dist/outbound-media-contract-CGss_QHy.js +163 -0
- package/dist/outbound-payload-test-api.js +2 -0
- package/dist/quoted-message-TENQzyxV.js +108 -0
- package/dist/reaction-level-CRVEVAfi.js +16 -0
- package/dist/reply-resolver.runtime-BRCgoO4C.js +2 -0
- package/dist/resolve-outbound-target-CN-Wo6IY.js +39 -0
- package/dist/rolldown-runtime-RkAeH_Qm.js +27 -0
- package/dist/runtime-6fZ67abR.js +8 -0
- package/dist/runtime-api.js +15 -0
- package/dist/runtime-group-policy-Gp1lQ0at.js +11 -0
- package/dist/secret-contract-api.js +5 -0
- package/dist/security-contract-DqH8JDX6.js +26 -0
- package/dist/security-contract-api.js +2 -0
- package/dist/send-CIyLFxdZ.js +234 -0
- package/dist/session-contract-B0efQf9P.js +27 -0
- package/dist/session-errors-CSuKZPub.js +63 -0
- package/dist/session.runtime-C1eSE_KK.js +13 -0
- package/dist/setup-core-DZKvpzbH.js +46 -0
- package/dist/setup-entry.js +23 -0
- package/dist/setup-plugin-api.js +2 -0
- package/dist/setup-surface-ieFnIW4g.js +344 -0
- package/dist/shared-D_wzSVar.js +307 -0
- package/dist/state-migrations-DnCdvoYD.js +39 -0
- package/dist/targets.js +2 -0
- package/dist/test-api.js +3 -0
- package/dist/text-runtime-C1zNiZeO.js +116 -0
- package/package.json +14 -6
- package/action-runtime-api.ts +0 -1
- package/action-runtime.runtime.ts +0 -1
- package/api.ts +0 -213
- package/auth-presence.ts +0 -80
- package/channel-config-api.ts +0 -1
- package/channel-plugin-api.ts +0 -3
- package/config-api.ts +0 -4
- package/constants.ts +0 -1
- package/contract-api.ts +0 -29
- package/directory-contract-api.ts +0 -4
- package/doctor-contract-api.ts +0 -8
- package/index.test.ts +0 -13
- package/index.ts +0 -16
- package/legacy-session-surface-api.ts +0 -6
- package/legacy-state-migrations-api.ts +0 -1
- package/light-runtime-api.ts +0 -12
- package/login-qr-api.ts +0 -1
- package/login-qr-runtime.ts +0 -23
- package/outbound-payload-test-api.ts +0 -1
- package/runtime-api.ts +0 -84
- package/secret-contract-api.ts +0 -4
- package/security-contract-api.ts +0 -4
- package/setup-entry.test.ts +0 -21
- package/setup-entry.ts +0 -21
- package/setup-plugin-api.ts +0 -3
- package/src/account-config.ts +0 -77
- package/src/account-ids.ts +0 -13
- package/src/account-types.ts +0 -5
- package/src/accounts.test.ts +0 -182
- package/src/accounts.ts +0 -176
- package/src/accounts.whatsapp-auth.test.ts +0 -59
- package/src/action-runtime-target-auth.ts +0 -27
- package/src/action-runtime.test.ts +0 -330
- package/src/action-runtime.ts +0 -76
- package/src/active-listener.test.ts +0 -65
- package/src/active-listener.ts +0 -17
- package/src/agent-tools-login.test.ts +0 -81
- package/src/agent-tools-login.ts +0 -113
- package/src/approval-auth.test.ts +0 -24
- package/src/approval-auth.ts +0 -27
- package/src/auth-store.runtime.ts +0 -1
- package/src/auth-store.test.ts +0 -311
- package/src/auth-store.ts +0 -502
- package/src/auto-reply/config.runtime.ts +0 -16
- package/src/auto-reply/constants.ts +0 -1
- package/src/auto-reply/deliver-reply.test.ts +0 -843
- package/src/auto-reply/deliver-reply.ts +0 -279
- package/src/auto-reply/loggers.ts +0 -6
- package/src/auto-reply/mentions.ts +0 -131
- package/src/auto-reply/monitor/ack-reaction.test.ts +0 -170
- package/src/auto-reply/monitor/ack-reaction.ts +0 -99
- package/src/auto-reply/monitor/audio-preflight.runtime.ts +0 -9
- package/src/auto-reply/monitor/broadcast.ts +0 -153
- package/src/auto-reply/monitor/commands.ts +0 -19
- package/src/auto-reply/monitor/echo.ts +0 -64
- package/src/auto-reply/monitor/group-activation.runtime.ts +0 -1
- package/src/auto-reply/monitor/group-activation.test.ts +0 -189
- package/src/auto-reply/monitor/group-activation.ts +0 -73
- package/src/auto-reply/monitor/group-gating.audio-preflight.test.ts +0 -103
- package/src/auto-reply/monitor/group-gating.runtime.ts +0 -8
- package/src/auto-reply/monitor/group-gating.ts +0 -217
- package/src/auto-reply/monitor/group-members.test.ts +0 -56
- package/src/auto-reply/monitor/group-members.ts +0 -65
- package/src/auto-reply/monitor/inbound-context.test.ts +0 -97
- package/src/auto-reply/monitor/inbound-context.ts +0 -92
- package/src/auto-reply/monitor/inbound-dispatch.runtime.ts +0 -21
- package/src/auto-reply/monitor/inbound-dispatch.test.ts +0 -895
- package/src/auto-reply/monitor/inbound-dispatch.ts +0 -422
- package/src/auto-reply/monitor/last-route.test.ts +0 -37
- package/src/auto-reply/monitor/last-route.ts +0 -61
- package/src/auto-reply/monitor/message-line.runtime.ts +0 -38
- package/src/auto-reply/monitor/message-line.ts +0 -54
- package/src/auto-reply/monitor/on-message.audio-preflight.test.ts +0 -354
- package/src/auto-reply/monitor/on-message.ts +0 -291
- package/src/auto-reply/monitor/peer.ts +0 -17
- package/src/auto-reply/monitor/process-message.audio-preflight.test.ts +0 -420
- package/src/auto-reply/monitor/process-message.test.ts +0 -355
- package/src/auto-reply/monitor/process-message.ts +0 -531
- package/src/auto-reply/monitor/runtime-api.ts +0 -30
- package/src/auto-reply/monitor-state.test.ts +0 -64
- package/src/auto-reply/monitor-state.ts +0 -106
- package/src/auto-reply/monitor.ts +0 -600
- package/src/auto-reply/reply-resolver.runtime.ts +0 -1
- package/src/auto-reply/types.ts +0 -48
- package/src/auto-reply/util.ts +0 -63
- package/src/auto-reply/web-auto-reply-monitor.test.ts +0 -687
- package/src/auto-reply/web-auto-reply-utils.test.ts +0 -392
- package/src/auto-reply.broadcast-groups.combined.test.ts +0 -246
- package/src/auto-reply.broadcast-groups.test-harness.ts +0 -47
- package/src/auto-reply.impl.ts +0 -6
- package/src/auto-reply.test-harness.ts +0 -421
- package/src/auto-reply.ts +0 -1
- package/src/auto-reply.web-auto-reply.compresses-common-formats-jpeg-cap.test.ts +0 -427
- package/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts +0 -908
- package/src/auto-reply.web-auto-reply.last-route.test.ts +0 -184
- package/src/channel-actions.runtime.ts +0 -7
- package/src/channel-actions.test.ts +0 -216
- package/src/channel-actions.ts +0 -84
- package/src/channel-outbound.test.ts +0 -131
- package/src/channel-outbound.ts +0 -36
- package/src/channel-react-action.runtime.ts +0 -7
- package/src/channel-react-action.test.ts +0 -294
- package/src/channel-react-action.ts +0 -84
- package/src/channel.runtime.ts +0 -117
- package/src/channel.setup.test.ts +0 -461
- package/src/channel.setup.ts +0 -28
- package/src/channel.ts +0 -334
- package/src/command-policy.ts +0 -7
- package/src/config-accessors.test.ts +0 -34
- package/src/config-accessors.ts +0 -22
- package/src/config-schema.test.ts +0 -121
- package/src/config-schema.ts +0 -6
- package/src/config-ui-hints.ts +0 -24
- package/src/connection-controller-registry.test.ts +0 -27
- package/src/connection-controller-registry.ts +0 -49
- package/src/connection-controller.test.ts +0 -282
- package/src/connection-controller.ts +0 -679
- package/src/creds-files.ts +0 -19
- package/src/creds-persistence.ts +0 -102
- package/src/directory-config.test.ts +0 -60
- package/src/directory-config.ts +0 -40
- package/src/directory-contract.test.ts +0 -56
- package/src/doctor-contract.ts +0 -11
- package/src/doctor.test.ts +0 -74
- package/src/doctor.ts +0 -56
- package/src/group-intro.ts +0 -15
- package/src/group-policy.test.ts +0 -36
- package/src/group-policy.ts +0 -40
- package/src/group-session-contract.ts +0 -20
- package/src/group-session-key.test.ts +0 -53
- package/src/group-session-key.ts +0 -41
- package/src/heartbeat.ts +0 -34
- package/src/identity.ts +0 -164
- package/src/inbound/access-control.test-harness.ts +0 -37
- package/src/inbound/access-control.test.ts +0 -375
- package/src/inbound/access-control.ts +0 -237
- package/src/inbound/dedupe.ts +0 -132
- package/src/inbound/extract.test.ts +0 -282
- package/src/inbound/extract.ts +0 -488
- package/src/inbound/lifecycle.ts +0 -39
- package/src/inbound/media.node.test.ts +0 -83
- package/src/inbound/media.ts +0 -102
- package/src/inbound/monitor.ts +0 -890
- package/src/inbound/runtime-api.ts +0 -7
- package/src/inbound/save-media.runtime.ts +0 -1
- package/src/inbound/send-api.test.ts +0 -307
- package/src/inbound/send-api.ts +0 -141
- package/src/inbound/send-result.ts +0 -61
- package/src/inbound/types.ts +0 -106
- package/src/inbound-context.contract.test.ts +0 -32
- package/src/inbound-policy.ts +0 -231
- package/src/inbound.media.test.ts +0 -320
- package/src/inbound.test.ts +0 -290
- package/src/inbound.ts +0 -9
- package/src/login-qr.test.ts +0 -483
- package/src/login-qr.ts +0 -542
- package/src/login.coverage.test.ts +0 -133
- package/src/login.test.ts +0 -89
- package/src/login.ts +0 -70
- package/src/logout.test.ts +0 -162
- package/src/media.test.ts +0 -480
- package/src/media.ts +0 -10
- package/src/monitor-inbox.allows-messages-from-senders-allowfrom-list.test-support.ts +0 -400
- package/src/monitor-inbox.append-upsert.test-support.ts +0 -133
- package/src/monitor-inbox.behavior.test.ts +0 -5
- package/src/monitor-inbox.blocks-messages-from-unauthorized-senders-not-allowfrom.test-support.ts +0 -362
- package/src/monitor-inbox.captures-media-path-image-messages.test-support.ts +0 -306
- package/src/monitor-inbox.streams-inbound-messages.test-support.ts +0 -729
- package/src/monitor-inbox.test-harness.ts +0 -304
- package/src/normalize-target.ts +0 -112
- package/src/normalize.ts +0 -6
- package/src/outbound-adapter.poll.test.ts +0 -62
- package/src/outbound-adapter.sendpayload.test.ts +0 -195
- package/src/outbound-adapter.ts +0 -36
- package/src/outbound-base.test.ts +0 -560
- package/src/outbound-base.ts +0 -244
- package/src/outbound-media-contract.ts +0 -278
- package/src/outbound-media.runtime.ts +0 -36
- package/src/outbound-payload.contract.test.ts +0 -61
- package/src/outbound-send-deps.ts +0 -1
- package/src/outbound-test-support.ts +0 -16
- package/src/pairing-security.test-harness.ts +0 -59
- package/src/qr-image.ts +0 -1
- package/src/qr-terminal.ts +0 -1
- package/src/quoted-message.test.ts +0 -83
- package/src/quoted-message.ts +0 -184
- package/src/reaction-level.test.ts +0 -94
- package/src/reaction-level.ts +0 -21
- package/src/reconnect.test.ts +0 -51
- package/src/reconnect.ts +0 -55
- package/src/resolve-outbound-target.test.ts +0 -265
- package/src/resolve-outbound-target.ts +0 -54
- package/src/resolve-target.test.ts +0 -97
- package/src/runtime-api.ts +0 -59
- package/src/runtime-group-policy.ts +0 -16
- package/src/runtime.ts +0 -9
- package/src/security-contract.ts +0 -47
- package/src/security-fix.ts +0 -71
- package/src/send.test.ts +0 -515
- package/src/send.ts +0 -287
- package/src/session-contract.test.ts +0 -31
- package/src/session-contract.ts +0 -43
- package/src/session-errors.ts +0 -125
- package/src/session-route.ts +0 -26
- package/src/session.runtime.ts +0 -8
- package/src/session.test.ts +0 -559
- package/src/session.ts +0 -330
- package/src/setup-core.ts +0 -52
- package/src/setup-finalize.ts +0 -446
- package/src/setup-surface.test.ts +0 -367
- package/src/setup-surface.ts +0 -69
- package/src/setup-test-helpers.ts +0 -216
- package/src/shared.ts +0 -291
- package/src/socket-timing.test.ts +0 -49
- package/src/socket-timing.ts +0 -38
- package/src/state-migrations.ts +0 -54
- package/src/status-issues.test.ts +0 -137
- package/src/status-issues.ts +0 -185
- package/src/system-prompt.test.ts +0 -199
- package/src/system-prompt.ts +0 -31
- package/src/targets-runtime.ts +0 -180
- package/src/test-helpers.ts +0 -690
- package/src/text-runtime.test.ts +0 -162
- package/src/text-runtime.ts +0 -11
- package/src/vcard.ts +0 -84
- package/targets.ts +0 -5
- package/test-api.ts +0 -2
- package/tsconfig.json +0 -16
package/src/inbound-policy.ts
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
resolveChannelGroupPolicy,
|
|
3
|
-
resolveChannelGroupRequireMention,
|
|
4
|
-
} from "openclaw/plugin-sdk/channel-policy";
|
|
5
|
-
import type {
|
|
6
|
-
ChannelGroupPolicy,
|
|
7
|
-
DmPolicy,
|
|
8
|
-
GroupPolicy,
|
|
9
|
-
OpenClawConfig,
|
|
10
|
-
} from "openclaw/plugin-sdk/config-types";
|
|
11
|
-
import { resolveDefaultGroupPolicy } from "openclaw/plugin-sdk/runtime-group-policy";
|
|
12
|
-
import {
|
|
13
|
-
expandAllowFromWithAccessGroups,
|
|
14
|
-
readStoreAllowFromForDmPolicy,
|
|
15
|
-
resolveEffectiveAllowFromLists,
|
|
16
|
-
resolveDmGroupAccessWithCommandGate,
|
|
17
|
-
} from "openclaw/plugin-sdk/security-runtime";
|
|
18
|
-
import { resolveGroupSessionKey } from "openclaw/plugin-sdk/session-store-runtime";
|
|
19
|
-
import { resolveWhatsAppAccount, type ResolvedWhatsAppAccount } from "./accounts.js";
|
|
20
|
-
import { getSelfIdentity, getSenderIdentity } from "./identity.js";
|
|
21
|
-
import type { WebInboundMessage } from "./inbound/types.js";
|
|
22
|
-
import { resolveWhatsAppRuntimeGroupPolicy } from "./runtime-group-policy.js";
|
|
23
|
-
import { isSelfChatMode, normalizeE164 } from "./text-runtime.js";
|
|
24
|
-
|
|
25
|
-
export type ResolvedWhatsAppInboundPolicy = {
|
|
26
|
-
account: ResolvedWhatsAppAccount;
|
|
27
|
-
dmPolicy: DmPolicy;
|
|
28
|
-
groupPolicy: GroupPolicy;
|
|
29
|
-
configuredAllowFrom: string[];
|
|
30
|
-
dmAllowFrom: string[];
|
|
31
|
-
groupAllowFrom: string[];
|
|
32
|
-
isSelfChat: boolean;
|
|
33
|
-
providerMissingFallbackApplied: boolean;
|
|
34
|
-
shouldReadStorePairingApprovals: boolean;
|
|
35
|
-
isSamePhone: (value?: string | null) => boolean;
|
|
36
|
-
isDmSenderAllowed: (allowEntries: string[], sender?: string | null) => boolean;
|
|
37
|
-
isGroupSenderAllowed: (allowEntries: string[], sender?: string | null) => boolean;
|
|
38
|
-
resolveConversationGroupPolicy: (conversationId: string) => ChannelGroupPolicy;
|
|
39
|
-
resolveConversationRequireMention: (conversationId: string) => boolean;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
function resolveGroupConversationId(conversationId: string): string {
|
|
43
|
-
return (
|
|
44
|
-
resolveGroupSessionKey({
|
|
45
|
-
From: conversationId,
|
|
46
|
-
ChatType: "group",
|
|
47
|
-
Provider: "whatsapp",
|
|
48
|
-
})?.id ?? conversationId
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function isNormalizedSenderAllowed(allowEntries: string[], sender?: string | null): boolean {
|
|
53
|
-
if (allowEntries.includes("*")) {
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
const normalizedSender = normalizeE164(sender ?? "");
|
|
57
|
-
if (!normalizedSender) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
const normalizedEntrySet = new Set(
|
|
61
|
-
allowEntries
|
|
62
|
-
.map((entry) => normalizeE164(entry))
|
|
63
|
-
.filter((entry): entry is string => Boolean(entry)),
|
|
64
|
-
);
|
|
65
|
-
return normalizedEntrySet.has(normalizedSender);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function buildResolvedWhatsAppGroupConfig(params: {
|
|
69
|
-
groupPolicy: GroupPolicy;
|
|
70
|
-
groups: ResolvedWhatsAppAccount["groups"];
|
|
71
|
-
}): OpenClawConfig {
|
|
72
|
-
return {
|
|
73
|
-
channels: {
|
|
74
|
-
whatsapp: {
|
|
75
|
-
groupPolicy: params.groupPolicy,
|
|
76
|
-
groups: params.groups,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
} as OpenClawConfig;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function resolveWhatsAppInboundPolicy(params: {
|
|
83
|
-
cfg: OpenClawConfig;
|
|
84
|
-
accountId?: string | null;
|
|
85
|
-
selfE164?: string | null;
|
|
86
|
-
}): ResolvedWhatsAppInboundPolicy {
|
|
87
|
-
const account = resolveWhatsAppAccount({
|
|
88
|
-
cfg: params.cfg,
|
|
89
|
-
accountId: params.accountId,
|
|
90
|
-
});
|
|
91
|
-
const configuredAllowFrom = account.allowFrom ?? [];
|
|
92
|
-
const dmPolicy = account.dmPolicy ?? "pairing";
|
|
93
|
-
const dmAllowFrom =
|
|
94
|
-
configuredAllowFrom.length > 0 ? configuredAllowFrom : params.selfE164 ? [params.selfE164] : [];
|
|
95
|
-
const groupAllowFrom =
|
|
96
|
-
account.groupAllowFrom ??
|
|
97
|
-
(configuredAllowFrom.length > 0 ? configuredAllowFrom : undefined) ??
|
|
98
|
-
[];
|
|
99
|
-
const { effectiveGroupAllowFrom } = resolveEffectiveAllowFromLists({
|
|
100
|
-
allowFrom: configuredAllowFrom,
|
|
101
|
-
groupAllowFrom,
|
|
102
|
-
});
|
|
103
|
-
const defaultGroupPolicy = resolveDefaultGroupPolicy(params.cfg);
|
|
104
|
-
const { groupPolicy, providerMissingFallbackApplied } = resolveWhatsAppRuntimeGroupPolicy({
|
|
105
|
-
providerConfigPresent: params.cfg.channels?.whatsapp !== undefined,
|
|
106
|
-
groupPolicy: account.groupPolicy,
|
|
107
|
-
defaultGroupPolicy,
|
|
108
|
-
});
|
|
109
|
-
const resolvedGroupCfg = buildResolvedWhatsAppGroupConfig({
|
|
110
|
-
groupPolicy,
|
|
111
|
-
groups: account.groups,
|
|
112
|
-
});
|
|
113
|
-
const isSamePhone = (value?: string | null) =>
|
|
114
|
-
typeof value === "string" && typeof params.selfE164 === "string" && value === params.selfE164;
|
|
115
|
-
return {
|
|
116
|
-
account,
|
|
117
|
-
dmPolicy,
|
|
118
|
-
groupPolicy,
|
|
119
|
-
configuredAllowFrom,
|
|
120
|
-
dmAllowFrom,
|
|
121
|
-
groupAllowFrom,
|
|
122
|
-
isSelfChat: account.selfChatMode ?? isSelfChatMode(params.selfE164, configuredAllowFrom),
|
|
123
|
-
providerMissingFallbackApplied,
|
|
124
|
-
shouldReadStorePairingApprovals: dmPolicy !== "allowlist",
|
|
125
|
-
isSamePhone,
|
|
126
|
-
isDmSenderAllowed: (allowEntries, sender) =>
|
|
127
|
-
isSamePhone(sender) || isNormalizedSenderAllowed(allowEntries, sender),
|
|
128
|
-
isGroupSenderAllowed: (allowEntries, sender) => isNormalizedSenderAllowed(allowEntries, sender),
|
|
129
|
-
resolveConversationGroupPolicy: (conversationId) =>
|
|
130
|
-
resolveChannelGroupPolicy({
|
|
131
|
-
cfg: resolvedGroupCfg,
|
|
132
|
-
channel: "whatsapp",
|
|
133
|
-
groupId: resolveGroupConversationId(conversationId),
|
|
134
|
-
hasGroupAllowFrom: effectiveGroupAllowFrom.length > 0,
|
|
135
|
-
}),
|
|
136
|
-
resolveConversationRequireMention: (conversationId) =>
|
|
137
|
-
resolveChannelGroupRequireMention({
|
|
138
|
-
cfg: resolvedGroupCfg,
|
|
139
|
-
channel: "whatsapp",
|
|
140
|
-
groupId: resolveGroupConversationId(conversationId),
|
|
141
|
-
}),
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export async function resolveWhatsAppCommandAuthorized(params: {
|
|
146
|
-
cfg: OpenClawConfig;
|
|
147
|
-
msg: WebInboundMessage;
|
|
148
|
-
policy?: ResolvedWhatsAppInboundPolicy;
|
|
149
|
-
}): Promise<boolean> {
|
|
150
|
-
const useAccessGroups = params.cfg.commands?.useAccessGroups !== false;
|
|
151
|
-
if (!useAccessGroups) {
|
|
152
|
-
return true;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const self = getSelfIdentity(params.msg);
|
|
156
|
-
const policy =
|
|
157
|
-
params.policy ??
|
|
158
|
-
resolveWhatsAppInboundPolicy({
|
|
159
|
-
cfg: params.cfg,
|
|
160
|
-
accountId: params.msg.accountId,
|
|
161
|
-
selfE164: self.e164 ?? null,
|
|
162
|
-
});
|
|
163
|
-
const isGroup = params.msg.chatType === "group";
|
|
164
|
-
const sender = getSenderIdentity(params.msg);
|
|
165
|
-
const dmSender = sender.e164 ?? params.msg.from ?? "";
|
|
166
|
-
const groupSender = sender.e164 ?? "";
|
|
167
|
-
const normalizedSender = normalizeE164(isGroup ? groupSender : dmSender);
|
|
168
|
-
if (!normalizedSender) {
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const storeAllowFrom =
|
|
173
|
-
isGroup || !policy.shouldReadStorePairingApprovals
|
|
174
|
-
? []
|
|
175
|
-
: await readStoreAllowFromForDmPolicy({
|
|
176
|
-
provider: "whatsapp",
|
|
177
|
-
accountId: policy.account.accountId,
|
|
178
|
-
dmPolicy: policy.dmPolicy,
|
|
179
|
-
shouldRead: policy.shouldReadStorePairingApprovals,
|
|
180
|
-
});
|
|
181
|
-
const isSenderAllowed = (senderId: string, allowEntries: string[]) =>
|
|
182
|
-
isGroup
|
|
183
|
-
? policy.isGroupSenderAllowed(allowEntries, senderId)
|
|
184
|
-
: policy.isDmSenderAllowed(allowEntries, senderId);
|
|
185
|
-
const [allowFrom, groupAllowFrom] = await Promise.all([
|
|
186
|
-
expandAllowFromWithAccessGroups({
|
|
187
|
-
cfg: params.cfg,
|
|
188
|
-
allowFrom: policy.dmAllowFrom,
|
|
189
|
-
channel: "whatsapp",
|
|
190
|
-
accountId: policy.account.accountId,
|
|
191
|
-
senderId: normalizedSender,
|
|
192
|
-
isSenderAllowed,
|
|
193
|
-
}),
|
|
194
|
-
expandAllowFromWithAccessGroups({
|
|
195
|
-
cfg: params.cfg,
|
|
196
|
-
allowFrom: policy.groupAllowFrom,
|
|
197
|
-
channel: "whatsapp",
|
|
198
|
-
accountId: policy.account.accountId,
|
|
199
|
-
senderId: normalizedSender,
|
|
200
|
-
isSenderAllowed,
|
|
201
|
-
}),
|
|
202
|
-
]);
|
|
203
|
-
const dmStoreAllowFrom = isGroup
|
|
204
|
-
? []
|
|
205
|
-
: await expandAllowFromWithAccessGroups({
|
|
206
|
-
cfg: params.cfg,
|
|
207
|
-
allowFrom: storeAllowFrom,
|
|
208
|
-
channel: "whatsapp",
|
|
209
|
-
accountId: policy.account.accountId,
|
|
210
|
-
senderId: normalizedSender,
|
|
211
|
-
isSenderAllowed,
|
|
212
|
-
});
|
|
213
|
-
const access = resolveDmGroupAccessWithCommandGate({
|
|
214
|
-
isGroup,
|
|
215
|
-
dmPolicy: policy.dmPolicy,
|
|
216
|
-
groupPolicy: policy.groupPolicy,
|
|
217
|
-
allowFrom,
|
|
218
|
-
groupAllowFrom,
|
|
219
|
-
storeAllowFrom: dmStoreAllowFrom,
|
|
220
|
-
isSenderAllowed: (allowEntries) =>
|
|
221
|
-
isGroup
|
|
222
|
-
? policy.isGroupSenderAllowed(allowEntries, groupSender)
|
|
223
|
-
: policy.isDmSenderAllowed(allowEntries, dmSender),
|
|
224
|
-
command: {
|
|
225
|
-
useAccessGroups,
|
|
226
|
-
allowTextCommands: true,
|
|
227
|
-
hasControlCommand: true,
|
|
228
|
-
},
|
|
229
|
-
});
|
|
230
|
-
return access.commandAuthorized;
|
|
231
|
-
}
|
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import crypto from "node:crypto";
|
|
2
|
-
import fs from "node:fs/promises";
|
|
3
|
-
import os from "node:os";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
|
-
import {
|
|
7
|
-
mockExtractMessageContent,
|
|
8
|
-
mockGetContentType,
|
|
9
|
-
mockIsJidGroup,
|
|
10
|
-
mockNormalizeMessageContent,
|
|
11
|
-
} from "../../../test/mocks/baileys.js";
|
|
12
|
-
|
|
13
|
-
type MockMessageInput = Parameters<typeof mockNormalizeMessageContent>[0];
|
|
14
|
-
|
|
15
|
-
const readAllowFromStoreMock = vi.fn().mockResolvedValue([]);
|
|
16
|
-
const upsertPairingRequestMock = vi.fn().mockResolvedValue({ code: "PAIRCODE", created: true });
|
|
17
|
-
const saveMediaBufferSpy = vi.fn();
|
|
18
|
-
let currentMockSocket:
|
|
19
|
-
| {
|
|
20
|
-
ev: import("node:events").EventEmitter;
|
|
21
|
-
ws: { close: ReturnType<typeof vi.fn> };
|
|
22
|
-
sendPresenceUpdate: ReturnType<typeof vi.fn>;
|
|
23
|
-
sendMessage: ReturnType<typeof vi.fn>;
|
|
24
|
-
readMessages: ReturnType<typeof vi.fn>;
|
|
25
|
-
groupFetchAllParticipating: ReturnType<typeof vi.fn>;
|
|
26
|
-
updateMediaMessage: ReturnType<typeof vi.fn>;
|
|
27
|
-
logger: Record<string, never>;
|
|
28
|
-
user: { id: string };
|
|
29
|
-
}
|
|
30
|
-
| undefined;
|
|
31
|
-
|
|
32
|
-
vi.mock("openclaw/plugin-sdk/runtime-config-snapshot", async () => {
|
|
33
|
-
const actual = await vi.importActual<
|
|
34
|
-
typeof import("openclaw/plugin-sdk/runtime-config-snapshot")
|
|
35
|
-
>("openclaw/plugin-sdk/runtime-config-snapshot");
|
|
36
|
-
return {
|
|
37
|
-
...actual,
|
|
38
|
-
getRuntimeConfig: vi.fn().mockReturnValue({
|
|
39
|
-
channels: {
|
|
40
|
-
whatsapp: {
|
|
41
|
-
allowFrom: ["*"], // Allow all in tests
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
messages: {
|
|
45
|
-
messagePrefix: undefined,
|
|
46
|
-
responsePrefix: undefined,
|
|
47
|
-
},
|
|
48
|
-
}),
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
vi.mock("openclaw/plugin-sdk/conversation-runtime", async () => {
|
|
53
|
-
const actual = await vi.importActual<typeof import("openclaw/plugin-sdk/conversation-runtime")>(
|
|
54
|
-
"openclaw/plugin-sdk/conversation-runtime",
|
|
55
|
-
);
|
|
56
|
-
return {
|
|
57
|
-
...actual,
|
|
58
|
-
readChannelAllowFromStore(...args: unknown[]) {
|
|
59
|
-
return readAllowFromStoreMock(...args);
|
|
60
|
-
},
|
|
61
|
-
upsertChannelPairingRequest(...args: unknown[]) {
|
|
62
|
-
return upsertPairingRequestMock(...args);
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
vi.mock("openclaw/plugin-sdk/channel-pairing", async () => {
|
|
68
|
-
const actual = await vi.importActual<typeof import("openclaw/plugin-sdk/channel-pairing")>(
|
|
69
|
-
"openclaw/plugin-sdk/channel-pairing",
|
|
70
|
-
);
|
|
71
|
-
return {
|
|
72
|
-
...actual,
|
|
73
|
-
readChannelAllowFromStore(...args: unknown[]) {
|
|
74
|
-
return readAllowFromStoreMock(...args);
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
vi.mock("openclaw/plugin-sdk/media-store", async () => {
|
|
80
|
-
const actual = await vi.importActual<typeof import("openclaw/plugin-sdk/media-store")>(
|
|
81
|
-
"openclaw/plugin-sdk/media-store",
|
|
82
|
-
);
|
|
83
|
-
return {
|
|
84
|
-
...actual,
|
|
85
|
-
saveMediaBuffer: vi.fn(async (...args: Parameters<typeof actual.saveMediaBuffer>) => {
|
|
86
|
-
saveMediaBufferSpy(...args);
|
|
87
|
-
return actual.saveMediaBuffer(...args);
|
|
88
|
-
}),
|
|
89
|
-
};
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
const HOME = path.join(os.tmpdir(), `openclaw-inbound-media-${crypto.randomUUID()}`);
|
|
93
|
-
process.env.HOME = HOME;
|
|
94
|
-
|
|
95
|
-
vi.mock("@whiskeysockets/baileys", async () => {
|
|
96
|
-
const actual =
|
|
97
|
-
await vi.importActual<typeof import("@whiskeysockets/baileys")>("@whiskeysockets/baileys");
|
|
98
|
-
const jpegBuffer = Buffer.from([
|
|
99
|
-
0xff, 0xd8, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x02, 0x02,
|
|
100
|
-
0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x08, 0x06, 0x06, 0x05,
|
|
101
|
-
0x06, 0x09, 0x08, 0x0a, 0x0a, 0x09, 0x08, 0x09, 0x09, 0x0a, 0x0c, 0x0f, 0x0c, 0x0a, 0x0b, 0x0e,
|
|
102
|
-
0x0b, 0x09, 0x09, 0x0d, 0x11, 0x0d, 0x0e, 0x0f, 0x10, 0x10, 0x11, 0x10, 0x0a, 0x0c, 0x12, 0x13,
|
|
103
|
-
0x12, 0x10, 0x13, 0x0f, 0x10, 0x10, 0x10, 0xff, 0xc0, 0x00, 0x11, 0x08, 0x00, 0x01, 0x00, 0x01,
|
|
104
|
-
0x03, 0x01, 0x11, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xc4, 0x00, 0x14, 0x00, 0x01,
|
|
105
|
-
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
|
|
106
|
-
0xc4, 0x00, 0x14, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
107
|
-
0x00, 0x00, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00,
|
|
108
|
-
0xff, 0xd9,
|
|
109
|
-
]);
|
|
110
|
-
return {
|
|
111
|
-
...actual,
|
|
112
|
-
DisconnectReason: actual.DisconnectReason ?? { loggedOut: 401 },
|
|
113
|
-
downloadMediaMessage: vi.fn().mockResolvedValue(jpegBuffer),
|
|
114
|
-
extractMessageContent: vi.fn((message: MockMessageInput) => mockExtractMessageContent(message)),
|
|
115
|
-
getContentType: vi.fn((message: MockMessageInput) => mockGetContentType(message)),
|
|
116
|
-
isJidGroup: vi.fn((jid: string | undefined | null) => mockIsJidGroup(jid)),
|
|
117
|
-
normalizeMessageContent: vi.fn((message: MockMessageInput) =>
|
|
118
|
-
mockNormalizeMessageContent(message),
|
|
119
|
-
),
|
|
120
|
-
};
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
vi.mock("./session.js", async () => {
|
|
124
|
-
const actual = await vi.importActual<typeof import("./session.js")>("./session.js");
|
|
125
|
-
const { EventEmitter } = require("node:events");
|
|
126
|
-
return {
|
|
127
|
-
...actual,
|
|
128
|
-
createWaSocket: vi.fn().mockImplementation(async () => {
|
|
129
|
-
currentMockSocket ??= {
|
|
130
|
-
ev: new EventEmitter(),
|
|
131
|
-
ws: { close: vi.fn() },
|
|
132
|
-
sendPresenceUpdate: vi.fn().mockResolvedValue(undefined),
|
|
133
|
-
sendMessage: vi.fn().mockResolvedValue(undefined),
|
|
134
|
-
readMessages: vi.fn().mockResolvedValue(undefined),
|
|
135
|
-
groupFetchAllParticipating: vi.fn().mockResolvedValue({}),
|
|
136
|
-
updateMediaMessage: vi.fn(),
|
|
137
|
-
logger: {},
|
|
138
|
-
user: { id: "me@s.whatsapp.net" },
|
|
139
|
-
};
|
|
140
|
-
return currentMockSocket;
|
|
141
|
-
}),
|
|
142
|
-
waitForWaConnection: vi.fn().mockResolvedValue(undefined),
|
|
143
|
-
getStatusCode: vi.fn(() => 200),
|
|
144
|
-
};
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
let monitorWebInbox: typeof import("./inbound.js").monitorWebInbox;
|
|
148
|
-
let resetWebInboundDedupe: typeof import("./inbound.js").resetWebInboundDedupe;
|
|
149
|
-
let createWaSocket: typeof import("./session.js").createWaSocket;
|
|
150
|
-
|
|
151
|
-
async function waitForMessage(onMessage: ReturnType<typeof vi.fn>) {
|
|
152
|
-
await vi.waitFor(() => expect(onMessage).toHaveBeenCalledTimes(1), {
|
|
153
|
-
interval: 1,
|
|
154
|
-
timeout: 250,
|
|
155
|
-
});
|
|
156
|
-
return onMessage.mock.calls[0][0];
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
describe("web inbound media saves with extension", () => {
|
|
160
|
-
async function getMockSocket() {
|
|
161
|
-
return (await createWaSocket(false, false)) as unknown as {
|
|
162
|
-
ev: import("node:events").EventEmitter;
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
beforeEach(() => {
|
|
167
|
-
vi.useRealTimers();
|
|
168
|
-
currentMockSocket = undefined;
|
|
169
|
-
saveMediaBufferSpy.mockClear();
|
|
170
|
-
resetWebInboundDedupe();
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
beforeAll(async () => {
|
|
174
|
-
await fs.rm(HOME, { recursive: true, force: true });
|
|
175
|
-
({ monitorWebInbox, resetWebInboundDedupe } = await import("./inbound.js"));
|
|
176
|
-
({ createWaSocket } = await import("./session.js"));
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
afterAll(async () => {
|
|
180
|
-
await fs.rm(HOME, { recursive: true, force: true });
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it("stores image extension and keeps document filename", async () => {
|
|
184
|
-
const onMessage = vi.fn();
|
|
185
|
-
const listener = await monitorWebInbox({
|
|
186
|
-
cfg: {
|
|
187
|
-
channels: { whatsapp: { allowFrom: ["*"] } },
|
|
188
|
-
messages: { messagePrefix: undefined, responsePrefix: undefined },
|
|
189
|
-
} as never,
|
|
190
|
-
verbose: false,
|
|
191
|
-
onMessage,
|
|
192
|
-
accountId: "default",
|
|
193
|
-
authDir: path.join(HOME, "wa-auth"),
|
|
194
|
-
});
|
|
195
|
-
const realSock = await getMockSocket();
|
|
196
|
-
|
|
197
|
-
realSock.ev.emit("messages.upsert", {
|
|
198
|
-
type: "notify",
|
|
199
|
-
messages: [
|
|
200
|
-
{
|
|
201
|
-
key: { id: "img1", fromMe: false, remoteJid: "111@s.whatsapp.net" },
|
|
202
|
-
message: { imageMessage: { mimetype: "image/jpeg" } },
|
|
203
|
-
messageTimestamp: 1_700_000_001,
|
|
204
|
-
},
|
|
205
|
-
],
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
const first = await waitForMessage(onMessage);
|
|
209
|
-
const mediaPath = first.mediaPath;
|
|
210
|
-
expect(mediaPath).toBeDefined();
|
|
211
|
-
expect(path.extname(mediaPath as string)).toBe(".jpg");
|
|
212
|
-
const stat = await fs.stat(mediaPath as string);
|
|
213
|
-
expect(stat.size).toBeGreaterThan(0);
|
|
214
|
-
|
|
215
|
-
onMessage.mockClear();
|
|
216
|
-
const fileName = "invoice.pdf";
|
|
217
|
-
realSock.ev.emit("messages.upsert", {
|
|
218
|
-
type: "notify",
|
|
219
|
-
messages: [
|
|
220
|
-
{
|
|
221
|
-
key: { id: "doc1", fromMe: false, remoteJid: "333@s.whatsapp.net" },
|
|
222
|
-
message: { documentMessage: { mimetype: "application/pdf", fileName } },
|
|
223
|
-
messageTimestamp: 1_700_000_004,
|
|
224
|
-
},
|
|
225
|
-
],
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
const second = await waitForMessage(onMessage);
|
|
229
|
-
expect(second.mediaFileName).toBe(fileName);
|
|
230
|
-
expect(saveMediaBufferSpy).toHaveBeenCalled();
|
|
231
|
-
const lastCall = saveMediaBufferSpy.mock.calls.at(-1);
|
|
232
|
-
expect(lastCall?.[4]).toBe(fileName);
|
|
233
|
-
|
|
234
|
-
await listener.close();
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
it("stores quoted image media from reply context", async () => {
|
|
238
|
-
const onMessage = vi.fn();
|
|
239
|
-
const listener = await monitorWebInbox({
|
|
240
|
-
cfg: {
|
|
241
|
-
channels: { whatsapp: { allowFrom: ["*"] } },
|
|
242
|
-
messages: { messagePrefix: undefined, responsePrefix: undefined },
|
|
243
|
-
} as never,
|
|
244
|
-
verbose: false,
|
|
245
|
-
onMessage,
|
|
246
|
-
accountId: "default",
|
|
247
|
-
authDir: path.join(HOME, "wa-auth"),
|
|
248
|
-
});
|
|
249
|
-
const realSock = await getMockSocket();
|
|
250
|
-
|
|
251
|
-
realSock.ev.emit("messages.upsert", {
|
|
252
|
-
type: "notify",
|
|
253
|
-
messages: [
|
|
254
|
-
{
|
|
255
|
-
key: { id: "quote-img-reply", fromMe: false, remoteJid: "111@g.us" },
|
|
256
|
-
message: {
|
|
257
|
-
extendedTextMessage: {
|
|
258
|
-
text: "@bot what is this?",
|
|
259
|
-
contextInfo: {
|
|
260
|
-
stanzaId: "quoted-image",
|
|
261
|
-
participant: "222@s.whatsapp.net",
|
|
262
|
-
mentionedJid: ["me@s.whatsapp.net"],
|
|
263
|
-
quotedMessage: {
|
|
264
|
-
imageMessage: { mimetype: "image/jpeg" },
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
messageTimestamp: 1_700_000_005,
|
|
270
|
-
},
|
|
271
|
-
],
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
const inbound = await waitForMessage(onMessage);
|
|
275
|
-
expect(inbound.replyToBody).toBe("<media:image>");
|
|
276
|
-
expect(inbound.mediaPath).toBeDefined();
|
|
277
|
-
expect(path.extname(inbound.mediaPath as string)).toBe(".jpg");
|
|
278
|
-
expect(saveMediaBufferSpy).toHaveBeenCalled();
|
|
279
|
-
const lastCall = saveMediaBufferSpy.mock.calls.at(-1);
|
|
280
|
-
expect(lastCall?.[1]).toBe("image/jpeg");
|
|
281
|
-
|
|
282
|
-
await listener.close();
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
it("passes mediaMaxMb to saveMediaBuffer", async () => {
|
|
286
|
-
const onMessage = vi.fn();
|
|
287
|
-
const listener = await monitorWebInbox({
|
|
288
|
-
cfg: {
|
|
289
|
-
channels: { whatsapp: { allowFrom: ["*"] } },
|
|
290
|
-
messages: { messagePrefix: undefined, responsePrefix: undefined },
|
|
291
|
-
} as never,
|
|
292
|
-
verbose: false,
|
|
293
|
-
onMessage,
|
|
294
|
-
mediaMaxMb: 1,
|
|
295
|
-
accountId: "default",
|
|
296
|
-
authDir: path.join(HOME, "wa-auth"),
|
|
297
|
-
});
|
|
298
|
-
const realSock = await getMockSocket();
|
|
299
|
-
|
|
300
|
-
const upsert = {
|
|
301
|
-
type: "notify",
|
|
302
|
-
messages: [
|
|
303
|
-
{
|
|
304
|
-
key: { id: "img3", fromMe: false, remoteJid: "222@s.whatsapp.net" },
|
|
305
|
-
message: { imageMessage: { mimetype: "image/jpeg" } },
|
|
306
|
-
messageTimestamp: 1_700_000_003,
|
|
307
|
-
},
|
|
308
|
-
],
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
realSock.ev.emit("messages.upsert", upsert);
|
|
312
|
-
|
|
313
|
-
await waitForMessage(onMessage);
|
|
314
|
-
expect(saveMediaBufferSpy).toHaveBeenCalled();
|
|
315
|
-
const lastCall = saveMediaBufferSpy.mock.calls.at(-1);
|
|
316
|
-
expect(lastCall?.[3]).toBe(1 * 1024 * 1024);
|
|
317
|
-
|
|
318
|
-
await listener.close();
|
|
319
|
-
});
|
|
320
|
-
});
|