@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
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { createChannelPairingChallengeIssuer } from "openclaw/plugin-sdk/channel-pairing";
|
|
2
|
-
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-types";
|
|
3
|
-
import { upsertChannelPairingRequest } from "openclaw/plugin-sdk/conversation-runtime";
|
|
4
|
-
import { defaultRuntime } from "openclaw/plugin-sdk/runtime-env";
|
|
5
|
-
import { warnMissingProviderGroupPolicyFallbackOnce } from "openclaw/plugin-sdk/runtime-group-policy";
|
|
6
|
-
import {
|
|
7
|
-
expandAllowFromWithAccessGroups,
|
|
8
|
-
readStoreAllowFromForDmPolicy,
|
|
9
|
-
resolveDmGroupAccessWithLists,
|
|
10
|
-
} from "openclaw/plugin-sdk/security-runtime";
|
|
11
|
-
import { resolveWhatsAppInboundPolicy } from "../inbound-policy.js";
|
|
12
|
-
|
|
13
|
-
export type InboundAccessControlResult = {
|
|
14
|
-
allowed: boolean;
|
|
15
|
-
shouldMarkRead: boolean;
|
|
16
|
-
isSelfChat: boolean;
|
|
17
|
-
resolvedAccountId: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const PAIRING_REPLY_HISTORY_GRACE_MS = 30_000;
|
|
21
|
-
|
|
22
|
-
function logWhatsAppVerbose(enabled: boolean | undefined, message: string) {
|
|
23
|
-
if (!enabled) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
defaultRuntime.log(message);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export async function checkInboundAccessControl(params: {
|
|
30
|
-
cfg: OpenClawConfig;
|
|
31
|
-
accountId: string;
|
|
32
|
-
from: string;
|
|
33
|
-
selfE164: string | null;
|
|
34
|
-
senderE164: string | null;
|
|
35
|
-
group: boolean;
|
|
36
|
-
pushName?: string;
|
|
37
|
-
isFromMe: boolean;
|
|
38
|
-
messageTimestampMs?: number;
|
|
39
|
-
connectedAtMs?: number;
|
|
40
|
-
pairingGraceMs?: number;
|
|
41
|
-
verbose?: boolean;
|
|
42
|
-
sock: {
|
|
43
|
-
sendMessage: (jid: string, content: { text: string }) => Promise<unknown>;
|
|
44
|
-
};
|
|
45
|
-
remoteJid: string;
|
|
46
|
-
}): Promise<InboundAccessControlResult> {
|
|
47
|
-
const policy = resolveWhatsAppInboundPolicy({
|
|
48
|
-
cfg: params.cfg,
|
|
49
|
-
accountId: params.accountId,
|
|
50
|
-
selfE164: params.selfE164,
|
|
51
|
-
});
|
|
52
|
-
const storeAllowFrom = params.group
|
|
53
|
-
? []
|
|
54
|
-
: await readStoreAllowFromForDmPolicy({
|
|
55
|
-
provider: "whatsapp",
|
|
56
|
-
accountId: policy.account.accountId,
|
|
57
|
-
dmPolicy: policy.dmPolicy,
|
|
58
|
-
shouldRead: policy.shouldReadStorePairingApprovals,
|
|
59
|
-
});
|
|
60
|
-
const pairingGraceMs =
|
|
61
|
-
typeof params.pairingGraceMs === "number" && params.pairingGraceMs > 0
|
|
62
|
-
? params.pairingGraceMs
|
|
63
|
-
: PAIRING_REPLY_HISTORY_GRACE_MS;
|
|
64
|
-
const suppressPairingReply =
|
|
65
|
-
typeof params.connectedAtMs === "number" &&
|
|
66
|
-
typeof params.messageTimestampMs === "number" &&
|
|
67
|
-
params.messageTimestampMs < params.connectedAtMs - pairingGraceMs;
|
|
68
|
-
|
|
69
|
-
// Group policy filtering:
|
|
70
|
-
// - "open": groups bypass allowFrom, only mention-gating applies
|
|
71
|
-
// - "disabled": block all group messages entirely
|
|
72
|
-
// - "allowlist": only allow group messages from senders in groupAllowFrom/allowFrom
|
|
73
|
-
warnMissingProviderGroupPolicyFallbackOnce({
|
|
74
|
-
providerMissingFallbackApplied: policy.providerMissingFallbackApplied,
|
|
75
|
-
providerKey: "whatsapp",
|
|
76
|
-
accountId: policy.account.accountId,
|
|
77
|
-
log: (message) => logWhatsAppVerbose(params.verbose, message),
|
|
78
|
-
});
|
|
79
|
-
const accessGroupSenderId = params.group ? (params.senderE164 ?? params.from) : params.from;
|
|
80
|
-
const isAccessGroupSenderAllowed = (senderId: string, allowEntries: string[]) => {
|
|
81
|
-
return params.group
|
|
82
|
-
? policy.isGroupSenderAllowed(allowEntries, senderId)
|
|
83
|
-
: policy.isDmSenderAllowed(allowEntries, senderId);
|
|
84
|
-
};
|
|
85
|
-
const [allowFrom, groupAllowFrom] = await Promise.all([
|
|
86
|
-
expandAllowFromWithAccessGroups({
|
|
87
|
-
cfg: params.cfg,
|
|
88
|
-
allowFrom: params.group ? policy.configuredAllowFrom : policy.dmAllowFrom,
|
|
89
|
-
channel: "whatsapp",
|
|
90
|
-
accountId: policy.account.accountId,
|
|
91
|
-
senderId: accessGroupSenderId,
|
|
92
|
-
isSenderAllowed: isAccessGroupSenderAllowed,
|
|
93
|
-
}),
|
|
94
|
-
expandAllowFromWithAccessGroups({
|
|
95
|
-
cfg: params.cfg,
|
|
96
|
-
allowFrom: policy.groupAllowFrom,
|
|
97
|
-
channel: "whatsapp",
|
|
98
|
-
accountId: policy.account.accountId,
|
|
99
|
-
senderId: accessGroupSenderId,
|
|
100
|
-
isSenderAllowed: isAccessGroupSenderAllowed,
|
|
101
|
-
}),
|
|
102
|
-
]);
|
|
103
|
-
const dmStoreAllowFrom = params.group
|
|
104
|
-
? []
|
|
105
|
-
: await expandAllowFromWithAccessGroups({
|
|
106
|
-
cfg: params.cfg,
|
|
107
|
-
allowFrom: storeAllowFrom,
|
|
108
|
-
channel: "whatsapp",
|
|
109
|
-
accountId: policy.account.accountId,
|
|
110
|
-
senderId: accessGroupSenderId,
|
|
111
|
-
isSenderAllowed: isAccessGroupSenderAllowed,
|
|
112
|
-
});
|
|
113
|
-
const access = resolveDmGroupAccessWithLists({
|
|
114
|
-
isGroup: params.group,
|
|
115
|
-
dmPolicy: policy.dmPolicy,
|
|
116
|
-
groupPolicy: policy.groupPolicy,
|
|
117
|
-
allowFrom,
|
|
118
|
-
groupAllowFrom,
|
|
119
|
-
storeAllowFrom: dmStoreAllowFrom,
|
|
120
|
-
isSenderAllowed: (allowEntries) => {
|
|
121
|
-
return params.group
|
|
122
|
-
? policy.isGroupSenderAllowed(allowEntries, params.senderE164)
|
|
123
|
-
: policy.isDmSenderAllowed(allowEntries, params.from);
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
if (params.group && access.decision !== "allow") {
|
|
127
|
-
if (access.reason === "groupPolicy=disabled") {
|
|
128
|
-
logWhatsAppVerbose(params.verbose, "Blocked group message (groupPolicy: disabled)");
|
|
129
|
-
} else if (access.reason === "groupPolicy=allowlist (empty allowlist)") {
|
|
130
|
-
logWhatsAppVerbose(
|
|
131
|
-
params.verbose,
|
|
132
|
-
"Blocked group message (groupPolicy: allowlist, no groupAllowFrom)",
|
|
133
|
-
);
|
|
134
|
-
} else {
|
|
135
|
-
logWhatsAppVerbose(
|
|
136
|
-
params.verbose,
|
|
137
|
-
`Blocked group message from ${params.senderE164 ?? "unknown sender"} (groupPolicy: allowlist)`,
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
return {
|
|
141
|
-
allowed: false,
|
|
142
|
-
shouldMarkRead: false,
|
|
143
|
-
isSelfChat: policy.isSelfChat,
|
|
144
|
-
resolvedAccountId: policy.account.accountId,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// DM access control (secure defaults): "pairing" (default) / "allowlist" / "open" / "disabled".
|
|
149
|
-
if (!params.group) {
|
|
150
|
-
if (params.isFromMe && !policy.isSamePhone(params.from)) {
|
|
151
|
-
logWhatsAppVerbose(params.verbose, "Skipping outbound DM (fromMe); no pairing reply needed.");
|
|
152
|
-
return {
|
|
153
|
-
allowed: false,
|
|
154
|
-
shouldMarkRead: false,
|
|
155
|
-
isSelfChat: policy.isSelfChat,
|
|
156
|
-
resolvedAccountId: policy.account.accountId,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
if (access.decision === "block" && access.reason === "dmPolicy=disabled") {
|
|
160
|
-
logWhatsAppVerbose(params.verbose, "Blocked dm (dmPolicy: disabled)");
|
|
161
|
-
return {
|
|
162
|
-
allowed: false,
|
|
163
|
-
shouldMarkRead: false,
|
|
164
|
-
isSelfChat: policy.isSelfChat,
|
|
165
|
-
resolvedAccountId: policy.account.accountId,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
if (access.decision === "pairing" && !policy.isSamePhone(params.from)) {
|
|
169
|
-
const candidate = params.from;
|
|
170
|
-
if (suppressPairingReply) {
|
|
171
|
-
logWhatsAppVerbose(
|
|
172
|
-
params.verbose,
|
|
173
|
-
`Skipping pairing reply for historical DM from ${candidate}.`,
|
|
174
|
-
);
|
|
175
|
-
} else {
|
|
176
|
-
await createChannelPairingChallengeIssuer({
|
|
177
|
-
channel: "whatsapp",
|
|
178
|
-
upsertPairingRequest: async ({ id, meta }) =>
|
|
179
|
-
await upsertChannelPairingRequest({
|
|
180
|
-
channel: "whatsapp",
|
|
181
|
-
id,
|
|
182
|
-
accountId: policy.account.accountId,
|
|
183
|
-
meta,
|
|
184
|
-
}),
|
|
185
|
-
})({
|
|
186
|
-
senderId: candidate,
|
|
187
|
-
senderIdLine: `Your WhatsApp phone number: ${candidate}`,
|
|
188
|
-
meta: { name: (params.pushName ?? "").trim() || undefined },
|
|
189
|
-
onCreated: () => {
|
|
190
|
-
logWhatsAppVerbose(
|
|
191
|
-
params.verbose,
|
|
192
|
-
`whatsapp pairing request sender=${candidate} name=${params.pushName ?? "unknown"}`,
|
|
193
|
-
);
|
|
194
|
-
},
|
|
195
|
-
sendPairingReply: async (text) => {
|
|
196
|
-
await params.sock.sendMessage(params.remoteJid, { text });
|
|
197
|
-
},
|
|
198
|
-
onReplyError: (err) => {
|
|
199
|
-
logWhatsAppVerbose(
|
|
200
|
-
params.verbose,
|
|
201
|
-
`whatsapp pairing reply failed for ${candidate}: ${String(err)}`,
|
|
202
|
-
);
|
|
203
|
-
},
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
allowed: false,
|
|
208
|
-
shouldMarkRead: false,
|
|
209
|
-
isSelfChat: policy.isSelfChat,
|
|
210
|
-
resolvedAccountId: policy.account.accountId,
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
if (access.decision !== "allow") {
|
|
214
|
-
logWhatsAppVerbose(
|
|
215
|
-
params.verbose,
|
|
216
|
-
`Blocked unauthorized sender ${params.from} (dmPolicy=${policy.dmPolicy})`,
|
|
217
|
-
);
|
|
218
|
-
return {
|
|
219
|
-
allowed: false,
|
|
220
|
-
shouldMarkRead: false,
|
|
221
|
-
isSelfChat: policy.isSelfChat,
|
|
222
|
-
resolvedAccountId: policy.account.accountId,
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
return {
|
|
228
|
-
allowed: true,
|
|
229
|
-
shouldMarkRead: true,
|
|
230
|
-
isSelfChat: policy.isSelfChat,
|
|
231
|
-
resolvedAccountId: policy.account.accountId,
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
export const __testing = {
|
|
236
|
-
resolveWhatsAppInboundPolicy,
|
|
237
|
-
};
|
package/src/inbound/dedupe.ts
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { createClaimableDedupe } from "openclaw/plugin-sdk/persistent-dedupe";
|
|
2
|
-
|
|
3
|
-
const RECENT_WEB_MESSAGE_TTL_MS = 20 * 60_000;
|
|
4
|
-
const RECENT_WEB_MESSAGE_MAX = 5000;
|
|
5
|
-
const RECENT_OUTBOUND_MESSAGE_TTL_MS = 20 * 60_000;
|
|
6
|
-
const RECENT_OUTBOUND_MESSAGE_MAX = 5000;
|
|
7
|
-
|
|
8
|
-
const claimableInboundMessages = createClaimableDedupe({
|
|
9
|
-
ttlMs: RECENT_WEB_MESSAGE_TTL_MS,
|
|
10
|
-
memoryMaxSize: RECENT_WEB_MESSAGE_MAX,
|
|
11
|
-
});
|
|
12
|
-
const recentOutboundMessages = createRecentMessageCache({
|
|
13
|
-
ttlMs: RECENT_OUTBOUND_MESSAGE_TTL_MS,
|
|
14
|
-
maxSize: RECENT_OUTBOUND_MESSAGE_MAX,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
function createRecentMessageCache(options: { ttlMs: number; maxSize: number }) {
|
|
18
|
-
const ttlMs = Math.max(0, options.ttlMs);
|
|
19
|
-
const maxSize = Math.max(0, Math.floor(options.maxSize));
|
|
20
|
-
const cache = new Map<string, number>();
|
|
21
|
-
|
|
22
|
-
const prune = (now: number) => {
|
|
23
|
-
if (ttlMs > 0) {
|
|
24
|
-
const cutoff = now - ttlMs;
|
|
25
|
-
for (const [key, timestamp] of cache) {
|
|
26
|
-
if (timestamp < cutoff) {
|
|
27
|
-
cache.delete(key);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
while (cache.size > maxSize) {
|
|
32
|
-
const oldest = cache.keys().next().value;
|
|
33
|
-
if (!oldest) {
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
cache.delete(oldest);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const peek = (key: string | null, now = Date.now()): boolean => {
|
|
41
|
-
if (!key) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
const timestamp = cache.get(key);
|
|
45
|
-
if (timestamp === undefined) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
if (ttlMs > 0 && now - timestamp >= ttlMs) {
|
|
49
|
-
cache.delete(key);
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
return true;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
check: (key: string | null, now = Date.now()): boolean => {
|
|
57
|
-
if (!key) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
const existed = peek(key, now);
|
|
61
|
-
cache.delete(key);
|
|
62
|
-
cache.set(key, now);
|
|
63
|
-
prune(now);
|
|
64
|
-
return existed;
|
|
65
|
-
},
|
|
66
|
-
peek,
|
|
67
|
-
clear: () => cache.clear(),
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export class WhatsAppRetryableInboundError extends Error {
|
|
72
|
-
constructor(message: string, options?: ErrorOptions) {
|
|
73
|
-
super(message, options);
|
|
74
|
-
this.name = "WhatsAppRetryableInboundError";
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function buildMessageKey(params: {
|
|
79
|
-
accountId: string;
|
|
80
|
-
remoteJid: string;
|
|
81
|
-
messageId: string;
|
|
82
|
-
}): string | null {
|
|
83
|
-
const accountId = params.accountId.trim();
|
|
84
|
-
const remoteJid = params.remoteJid.trim();
|
|
85
|
-
const messageId = params.messageId.trim();
|
|
86
|
-
if (!accountId || !remoteJid || !messageId || messageId === "unknown") {
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
return `${accountId}:${remoteJid}:${messageId}`;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function resetWebInboundDedupe(): void {
|
|
93
|
-
claimableInboundMessages.clearMemory();
|
|
94
|
-
recentOutboundMessages.clear();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export async function claimRecentInboundMessage(key: string): Promise<boolean> {
|
|
98
|
-
const claim = await claimableInboundMessages.claim(key);
|
|
99
|
-
return claim.kind === "claimed";
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export async function commitRecentInboundMessage(key: string): Promise<void> {
|
|
103
|
-
await claimableInboundMessages.commit(key);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function releaseRecentInboundMessage(key: string, error?: unknown): void {
|
|
107
|
-
claimableInboundMessages.release(key, { error });
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export function rememberRecentOutboundMessage(params: {
|
|
111
|
-
accountId: string;
|
|
112
|
-
remoteJid: string;
|
|
113
|
-
messageId: string;
|
|
114
|
-
}): void {
|
|
115
|
-
const key = buildMessageKey(params);
|
|
116
|
-
if (!key) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
recentOutboundMessages.check(key);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export function isRecentOutboundMessage(params: {
|
|
123
|
-
accountId: string;
|
|
124
|
-
remoteJid: string;
|
|
125
|
-
messageId: string;
|
|
126
|
-
}): boolean {
|
|
127
|
-
const key = buildMessageKey(params);
|
|
128
|
-
if (!key) {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
return recentOutboundMessages.peek(key);
|
|
132
|
-
}
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
import type { proto } from "@whiskeysockets/baileys";
|
|
2
|
-
import { describe, expect, it } from "vitest";
|
|
3
|
-
import { extractMentionedJids, hasInboundUserContent } from "./extract.js";
|
|
4
|
-
|
|
5
|
-
describe("extractMentionedJids", () => {
|
|
6
|
-
const botJid = "5511999999999@s.whatsapp.net";
|
|
7
|
-
const otherJid = "5511888888888@s.whatsapp.net";
|
|
8
|
-
|
|
9
|
-
it("returns direct mentions from the current message", () => {
|
|
10
|
-
const message: proto.IMessage = {
|
|
11
|
-
extendedTextMessage: {
|
|
12
|
-
text: "Hey @bot",
|
|
13
|
-
contextInfo: {
|
|
14
|
-
mentionedJid: [botJid],
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
expect(extractMentionedJids(message)).toEqual([botJid]);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("ignores mentionedJids from quoted messages", () => {
|
|
22
|
-
const message: proto.IMessage = {
|
|
23
|
-
extendedTextMessage: {
|
|
24
|
-
text: "I agree",
|
|
25
|
-
contextInfo: {
|
|
26
|
-
// The quoted message originally @mentioned the bot, but the
|
|
27
|
-
// current message does not — this should NOT leak through.
|
|
28
|
-
quotedMessage: {
|
|
29
|
-
extendedTextMessage: {
|
|
30
|
-
text: "Hey @bot what do you think?",
|
|
31
|
-
contextInfo: {
|
|
32
|
-
mentionedJid: [botJid],
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
expect(extractMentionedJids(message)).toBeUndefined();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("returns direct mentions even when quoted message also has mentions", () => {
|
|
43
|
-
const message: proto.IMessage = {
|
|
44
|
-
extendedTextMessage: {
|
|
45
|
-
text: "Hey @other",
|
|
46
|
-
contextInfo: {
|
|
47
|
-
mentionedJid: [otherJid],
|
|
48
|
-
quotedMessage: {
|
|
49
|
-
extendedTextMessage: {
|
|
50
|
-
text: "Hey @bot",
|
|
51
|
-
contextInfo: {
|
|
52
|
-
mentionedJid: [botJid],
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
// Should return only the direct mention, not the quoted one.
|
|
60
|
-
expect(extractMentionedJids(message)).toEqual([otherJid]);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("returns mentions from media message types", () => {
|
|
64
|
-
const message: proto.IMessage = {
|
|
65
|
-
imageMessage: {
|
|
66
|
-
contextInfo: {
|
|
67
|
-
mentionedJid: [botJid],
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
expect(extractMentionedJids(message)).toEqual([botJid]);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("returns undefined for messages with no mentions", () => {
|
|
75
|
-
const message: proto.IMessage = {
|
|
76
|
-
extendedTextMessage: {
|
|
77
|
-
text: "Just a regular message",
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
expect(extractMentionedJids(message)).toBeUndefined();
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("returns undefined for undefined input", () => {
|
|
84
|
-
expect(extractMentionedJids(undefined)).toBeUndefined();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("deduplicates mentions across message types", () => {
|
|
88
|
-
const message: proto.IMessage = {
|
|
89
|
-
extendedTextMessage: {
|
|
90
|
-
text: "Hey @bot",
|
|
91
|
-
contextInfo: {
|
|
92
|
-
mentionedJid: [botJid],
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
imageMessage: {
|
|
96
|
-
contextInfo: {
|
|
97
|
-
mentionedJid: [botJid],
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
expect(extractMentionedJids(message)).toEqual([botJid]);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
describe("hasInboundUserContent", () => {
|
|
106
|
-
it("returns true for plain text conversation", () => {
|
|
107
|
-
expect(hasInboundUserContent({ conversation: "hello" })).toBe(true);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("returns true for extendedTextMessage", () => {
|
|
111
|
-
expect(
|
|
112
|
-
hasInboundUserContent({ extendedTextMessage: { text: "hello" } } as proto.IMessage),
|
|
113
|
-
).toBe(true);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("returns true for image message", () => {
|
|
117
|
-
expect(
|
|
118
|
-
hasInboundUserContent({ imageMessage: { mimetype: "image/png" } } as proto.IMessage),
|
|
119
|
-
).toBe(true);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it("returns true for video message", () => {
|
|
123
|
-
expect(
|
|
124
|
-
hasInboundUserContent({ videoMessage: { mimetype: "video/mp4" } } as proto.IMessage),
|
|
125
|
-
).toBe(true);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it("returns true for audio message", () => {
|
|
129
|
-
expect(
|
|
130
|
-
hasInboundUserContent({ audioMessage: { mimetype: "audio/ogg" } } as proto.IMessage),
|
|
131
|
-
).toBe(true);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it("returns true for document message", () => {
|
|
135
|
-
expect(
|
|
136
|
-
hasInboundUserContent({
|
|
137
|
-
documentMessage: { fileName: "x.pdf" },
|
|
138
|
-
} as proto.IMessage),
|
|
139
|
-
).toBe(true);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it("returns true for sticker message", () => {
|
|
143
|
-
expect(
|
|
144
|
-
hasInboundUserContent({ stickerMessage: { mimetype: "image/webp" } } as proto.IMessage),
|
|
145
|
-
).toBe(true);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it("returns true for location message with valid coords", () => {
|
|
149
|
-
expect(
|
|
150
|
-
hasInboundUserContent({
|
|
151
|
-
locationMessage: { degreesLatitude: 1, degreesLongitude: 2 },
|
|
152
|
-
} as proto.IMessage),
|
|
153
|
-
).toBe(true);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it("returns true for live location message with valid coords", () => {
|
|
157
|
-
expect(
|
|
158
|
-
hasInboundUserContent({
|
|
159
|
-
liveLocationMessage: { degreesLatitude: 1, degreesLongitude: 2 },
|
|
160
|
-
} as proto.IMessage),
|
|
161
|
-
).toBe(true);
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it("returns true for contact message", () => {
|
|
165
|
-
expect(
|
|
166
|
-
hasInboundUserContent({
|
|
167
|
-
contactMessage: { displayName: "Alice", vcard: "BEGIN:VCARD\nEND:VCARD" },
|
|
168
|
-
} as proto.IMessage),
|
|
169
|
-
).toBe(true);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it("returns true for contactsArrayMessage via contact placeholder extraction", () => {
|
|
173
|
-
expect(
|
|
174
|
-
hasInboundUserContent({
|
|
175
|
-
contactsArrayMessage: {
|
|
176
|
-
contacts: [{ displayName: "Alice", vcard: "BEGIN:VCARD\nEND:VCARD" }],
|
|
177
|
-
},
|
|
178
|
-
} as proto.IMessage),
|
|
179
|
-
).toBe(true);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it("returns true for buttons response (user button click)", () => {
|
|
183
|
-
expect(
|
|
184
|
-
hasInboundUserContent({
|
|
185
|
-
buttonsResponseMessage: {
|
|
186
|
-
selectedButtonId: "yes",
|
|
187
|
-
selectedDisplayText: "Yes",
|
|
188
|
-
},
|
|
189
|
-
} as proto.IMessage),
|
|
190
|
-
).toBe(true);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
it("returns true for list response (user list selection)", () => {
|
|
194
|
-
expect(
|
|
195
|
-
hasInboundUserContent({
|
|
196
|
-
listResponseMessage: {
|
|
197
|
-
title: "Option A",
|
|
198
|
-
singleSelectReply: { selectedRowId: "a" },
|
|
199
|
-
} as unknown as proto.Message.IListResponseMessage,
|
|
200
|
-
} as proto.IMessage),
|
|
201
|
-
).toBe(true);
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it("returns true for template button reply", () => {
|
|
205
|
-
expect(
|
|
206
|
-
hasInboundUserContent({
|
|
207
|
-
templateButtonReplyMessage: {
|
|
208
|
-
selectedId: "btn-1",
|
|
209
|
-
selectedDisplayText: "Click",
|
|
210
|
-
} as unknown as proto.Message.ITemplateButtonReplyMessage,
|
|
211
|
-
} as proto.IMessage),
|
|
212
|
-
).toBe(true);
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
it("returns true for interactive response", () => {
|
|
216
|
-
expect(
|
|
217
|
-
hasInboundUserContent({
|
|
218
|
-
interactiveResponseMessage: {
|
|
219
|
-
body: { text: "x" },
|
|
220
|
-
nativeFlowResponseMessage: { name: "n", paramsJson: "{}" },
|
|
221
|
-
} as unknown as proto.Message.IInteractiveResponseMessage,
|
|
222
|
-
} as proto.IMessage),
|
|
223
|
-
).toBe(true);
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it("returns true for buttons response wrapped in ephemeralMessage (regression for #73797 + greptile review)", () => {
|
|
227
|
-
expect(
|
|
228
|
-
hasInboundUserContent({
|
|
229
|
-
ephemeralMessage: {
|
|
230
|
-
message: {
|
|
231
|
-
buttonsResponseMessage: {
|
|
232
|
-
selectedButtonId: "ok",
|
|
233
|
-
selectedDisplayText: "OK",
|
|
234
|
-
},
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
} as proto.IMessage),
|
|
238
|
-
).toBe(true);
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it("returns false for undefined message (regression for #73797)", () => {
|
|
242
|
-
expect(hasInboundUserContent(undefined)).toBe(false);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it("returns false for empty message object (no content keys)", () => {
|
|
246
|
-
expect(hasInboundUserContent({} as proto.IMessage)).toBe(false);
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
it("returns false for protocol message envelope without inner content (regression for #73797)", () => {
|
|
250
|
-
expect(
|
|
251
|
-
hasInboundUserContent({
|
|
252
|
-
protocolMessage: {
|
|
253
|
-
type: 0,
|
|
254
|
-
} as unknown as proto.Message.IProtocolMessage,
|
|
255
|
-
} as proto.IMessage),
|
|
256
|
-
).toBe(false);
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
it("returns false for receipt-style senderKeyDistribution-only payload (regression for #73797)", () => {
|
|
260
|
-
expect(
|
|
261
|
-
hasInboundUserContent({
|
|
262
|
-
senderKeyDistributionMessage: {
|
|
263
|
-
groupId: "g@example",
|
|
264
|
-
} as unknown as proto.Message.ISenderKeyDistributionMessage,
|
|
265
|
-
} as proto.IMessage),
|
|
266
|
-
).toBe(false);
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
it("returns false when location coords are missing (incomplete event, regression for #73797)", () => {
|
|
270
|
-
expect(
|
|
271
|
-
hasInboundUserContent({
|
|
272
|
-
locationMessage: { name: "no coords" },
|
|
273
|
-
} as proto.IMessage),
|
|
274
|
-
).toBe(false);
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it("returns false when extendedTextMessage has only empty text", () => {
|
|
278
|
-
expect(hasInboundUserContent({ extendedTextMessage: { text: " " } } as proto.IMessage)).toBe(
|
|
279
|
-
false,
|
|
280
|
-
);
|
|
281
|
-
});
|
|
282
|
-
});
|