@gakr-gakr/whatsapp 0.1.0
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/action-runtime-api.ts +1 -0
- package/action-runtime.runtime.ts +1 -0
- package/api.ts +67 -0
- package/auth-presence.ts +80 -0
- package/autobot.plugin.json +23 -0
- package/channel-config-api.ts +1 -0
- package/channel-plugin-api.ts +3 -0
- package/config-api.ts +4 -0
- package/constants.ts +1 -0
- package/contract-api.ts +29 -0
- package/directory-contract-api.ts +4 -0
- package/doctor-contract-api.ts +8 -0
- package/index.ts +16 -0
- package/legacy-session-surface-api.ts +6 -0
- package/legacy-state-migrations-api.ts +1 -0
- package/light-runtime-api.ts +12 -0
- package/login-qr-api.ts +1 -0
- package/login-qr-runtime.ts +23 -0
- package/outbound-payload-test-api.ts +1 -0
- package/package.json +76 -0
- package/runtime-api.ts +84 -0
- package/secret-contract-api.ts +4 -0
- package/security-contract-api.ts +4 -0
- package/setup-entry.ts +21 -0
- package/setup-plugin-api.ts +3 -0
- package/src/account-config.ts +77 -0
- package/src/account-ids.ts +17 -0
- package/src/account-types.ts +5 -0
- package/src/accounts.ts +176 -0
- package/src/action-runtime-target-auth.ts +27 -0
- package/src/action-runtime.ts +76 -0
- package/src/active-listener.ts +17 -0
- package/src/agent-tools-login.ts +113 -0
- package/src/approval-auth.ts +27 -0
- package/src/auth-store.runtime.ts +1 -0
- package/src/auth-store.ts +494 -0
- package/src/auto-reply/config.runtime.ts +16 -0
- package/src/auto-reply/constants.ts +1 -0
- package/src/auto-reply/deliver-reply.ts +332 -0
- package/src/auto-reply/loggers.ts +6 -0
- package/src/auto-reply/mentions.ts +131 -0
- package/src/auto-reply/monitor/ack-reaction.ts +99 -0
- package/src/auto-reply/monitor/audio-preflight.runtime.ts +9 -0
- package/src/auto-reply/monitor/broadcast.ts +153 -0
- package/src/auto-reply/monitor/commands.ts +19 -0
- package/src/auto-reply/monitor/echo.ts +64 -0
- package/src/auto-reply/monitor/group-activation.runtime.ts +1 -0
- package/src/auto-reply/monitor/group-activation.ts +73 -0
- package/src/auto-reply/monitor/group-gating.runtime.ts +8 -0
- package/src/auto-reply/monitor/group-gating.ts +218 -0
- package/src/auto-reply/monitor/group-members.ts +65 -0
- package/src/auto-reply/monitor/inbound-context.ts +92 -0
- package/src/auto-reply/monitor/inbound-dispatch.runtime.ts +22 -0
- package/src/auto-reply/monitor/inbound-dispatch.ts +749 -0
- package/src/auto-reply/monitor/last-route.ts +61 -0
- package/src/auto-reply/monitor/listener-log.ts +28 -0
- package/src/auto-reply/monitor/message-line.runtime.ts +38 -0
- package/src/auto-reply/monitor/message-line.ts +54 -0
- package/src/auto-reply/monitor/on-message.ts +333 -0
- package/src/auto-reply/monitor/peer.ts +17 -0
- package/src/auto-reply/monitor/process-message.ts +584 -0
- package/src/auto-reply/monitor/runtime-api.ts +36 -0
- package/src/auto-reply/monitor/status-reaction.ts +108 -0
- package/src/auto-reply/monitor-state.ts +114 -0
- package/src/auto-reply/monitor.ts +720 -0
- package/src/auto-reply/reply-resolver.runtime.ts +1 -0
- package/src/auto-reply/types.ts +48 -0
- package/src/auto-reply/util.ts +62 -0
- package/src/auto-reply.impl.ts +6 -0
- package/src/auto-reply.ts +1 -0
- package/src/channel-actions.runtime.ts +7 -0
- package/src/channel-actions.ts +85 -0
- package/src/channel-outbound.ts +87 -0
- package/src/channel-react-action.runtime.ts +10 -0
- package/src/channel-react-action.ts +247 -0
- package/src/channel.runtime.ts +117 -0
- package/src/channel.setup.ts +32 -0
- package/src/channel.ts +356 -0
- package/src/command-policy.ts +7 -0
- package/src/config-accessors.ts +22 -0
- package/src/config-schema.ts +6 -0
- package/src/config-ui-hints.ts +24 -0
- package/src/connection-controller-registry.ts +49 -0
- package/src/connection-controller.ts +680 -0
- package/src/creds-files.ts +19 -0
- package/src/creds-persistence.ts +71 -0
- package/src/directory-config.ts +40 -0
- package/src/doctor-contract.ts +11 -0
- package/src/doctor.ts +56 -0
- package/src/document-filename.ts +17 -0
- package/src/group-intro.ts +15 -0
- package/src/group-policy.ts +40 -0
- package/src/group-session-contract.ts +20 -0
- package/src/group-session-key.ts +42 -0
- package/src/heartbeat.ts +34 -0
- package/src/identity.ts +164 -0
- package/src/inbound/access-control.ts +187 -0
- package/src/inbound/dedupe.ts +132 -0
- package/src/inbound/extract.ts +484 -0
- package/src/inbound/lifecycle.ts +39 -0
- package/src/inbound/media.ts +128 -0
- package/src/inbound/monitor.ts +1042 -0
- package/src/inbound/outbound-mentions.ts +260 -0
- package/src/inbound/runtime-api.ts +7 -0
- package/src/inbound/save-media.runtime.ts +1 -0
- package/src/inbound/send-api.ts +203 -0
- package/src/inbound/send-result.ts +109 -0
- package/src/inbound/types.ts +107 -0
- package/src/inbound-policy.ts +215 -0
- package/src/inbound.ts +9 -0
- package/src/login-qr.ts +542 -0
- package/src/login.ts +83 -0
- package/src/media.ts +10 -0
- package/src/monitor-inbox.allows-messages-from-senders-allowfrom-list.test-support.ts +417 -0
- package/src/monitor-inbox.append-upsert.test-support.ts +133 -0
- package/src/monitor-inbox.blocks-messages-from-unauthorized-senders-not-allowfrom.test-support.ts +418 -0
- package/src/monitor-inbox.captures-media-path-image-messages.test-support.ts +308 -0
- package/src/monitor-inbox.streams-inbound-messages.test-support.ts +824 -0
- package/src/normalize-target.ts +148 -0
- package/src/normalize.ts +8 -0
- package/src/outbound-adapter.ts +36 -0
- package/src/outbound-base.ts +256 -0
- package/src/outbound-media-contract.ts +307 -0
- package/src/outbound-media.runtime.ts +41 -0
- package/src/outbound-send-deps.ts +1 -0
- package/src/outbound-test-support.ts +16 -0
- package/src/qa-driver.runtime.ts +189 -0
- package/src/qr-image.ts +1 -0
- package/src/qr-terminal.ts +1 -0
- package/src/quoted-message.ts +184 -0
- package/src/reaction-level.ts +24 -0
- package/src/reconnect.ts +55 -0
- package/src/resolve-outbound-target.ts +58 -0
- package/src/runtime-api.ts +59 -0
- package/src/runtime-group-policy.ts +16 -0
- package/src/runtime.ts +9 -0
- package/src/security-contract.ts +47 -0
- package/src/security-fix.ts +71 -0
- package/src/send.ts +342 -0
- package/src/session-contract.ts +43 -0
- package/src/session-errors.ts +125 -0
- package/src/session-route.ts +32 -0
- package/src/session.runtime.ts +8 -0
- package/src/session.ts +327 -0
- package/src/setup-core.ts +52 -0
- package/src/setup-finalize.ts +450 -0
- package/src/setup-surface.ts +71 -0
- package/src/setup-test-helpers.ts +217 -0
- package/src/shared.ts +291 -0
- package/src/socket-timing.ts +38 -0
- package/src/state-migrations.ts +55 -0
- package/src/status-issues.ts +185 -0
- package/src/system-prompt.ts +31 -0
- package/src/targets-runtime.ts +221 -0
- package/src/text-runtime.ts +18 -0
- package/src/vcard.ts +84 -0
- package/targets.ts +5 -0
- package/test-api.ts +2 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { createChannelPairingChallengeIssuer } from "autobot/plugin-sdk/channel-pairing";
|
|
2
|
+
import type { AutoBotConfig } from "autobot/plugin-sdk/config-contracts";
|
|
3
|
+
import { upsertChannelPairingRequest } from "autobot/plugin-sdk/conversation-runtime";
|
|
4
|
+
import { defaultRuntime } from "autobot/plugin-sdk/runtime-env";
|
|
5
|
+
import { warnMissingProviderGroupPolicyFallbackOnce } from "autobot/plugin-sdk/runtime-group-policy";
|
|
6
|
+
import { resolveWhatsAppInboundPolicy, resolveWhatsAppIngressAccess } from "../inbound-policy.js";
|
|
7
|
+
|
|
8
|
+
export type InboundAccessControlResult = {
|
|
9
|
+
allowed: boolean;
|
|
10
|
+
shouldMarkRead: boolean;
|
|
11
|
+
isSelfChat: boolean;
|
|
12
|
+
resolvedAccountId: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const PAIRING_REPLY_HISTORY_GRACE_MS = 30_000;
|
|
16
|
+
|
|
17
|
+
function logWhatsAppVerbose(enabled: boolean | undefined, message: string) {
|
|
18
|
+
if (!enabled) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
defaultRuntime.log(message);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function checkInboundAccessControl(params: {
|
|
25
|
+
cfg: AutoBotConfig;
|
|
26
|
+
accountId: string;
|
|
27
|
+
from: string;
|
|
28
|
+
selfE164: string | null;
|
|
29
|
+
senderE164: string | null;
|
|
30
|
+
group: boolean;
|
|
31
|
+
pushName?: string;
|
|
32
|
+
isFromMe: boolean;
|
|
33
|
+
messageTimestampMs?: number;
|
|
34
|
+
connectedAtMs?: number;
|
|
35
|
+
pairingGraceMs?: number;
|
|
36
|
+
verbose?: boolean;
|
|
37
|
+
sock: {
|
|
38
|
+
sendMessage: (jid: string, content: { text: string }) => Promise<unknown>;
|
|
39
|
+
};
|
|
40
|
+
remoteJid: string;
|
|
41
|
+
}): Promise<InboundAccessControlResult> {
|
|
42
|
+
const policy = resolveWhatsAppInboundPolicy({
|
|
43
|
+
cfg: params.cfg,
|
|
44
|
+
accountId: params.accountId,
|
|
45
|
+
selfE164: params.selfE164,
|
|
46
|
+
});
|
|
47
|
+
const pairingGraceMs =
|
|
48
|
+
typeof params.pairingGraceMs === "number" && params.pairingGraceMs > 0
|
|
49
|
+
? params.pairingGraceMs
|
|
50
|
+
: PAIRING_REPLY_HISTORY_GRACE_MS;
|
|
51
|
+
const suppressPairingReply =
|
|
52
|
+
typeof params.connectedAtMs === "number" &&
|
|
53
|
+
typeof params.messageTimestampMs === "number" &&
|
|
54
|
+
params.messageTimestampMs < params.connectedAtMs - pairingGraceMs;
|
|
55
|
+
|
|
56
|
+
// Group policy filtering:
|
|
57
|
+
// - "open": groups bypass allowFrom, only mention-gating applies
|
|
58
|
+
// - "disabled": block all group messages entirely
|
|
59
|
+
// - "allowlist": only allow group messages from senders in groupAllowFrom/allowFrom
|
|
60
|
+
warnMissingProviderGroupPolicyFallbackOnce({
|
|
61
|
+
providerMissingFallbackApplied: policy.providerMissingFallbackApplied,
|
|
62
|
+
providerKey: "whatsapp",
|
|
63
|
+
accountId: policy.account.accountId,
|
|
64
|
+
log: (message) => logWhatsAppVerbose(params.verbose, message),
|
|
65
|
+
});
|
|
66
|
+
const access = await resolveWhatsAppIngressAccess({
|
|
67
|
+
cfg: params.cfg,
|
|
68
|
+
policy,
|
|
69
|
+
isGroup: params.group,
|
|
70
|
+
conversationId: params.remoteJid,
|
|
71
|
+
senderId: params.group ? params.senderE164 : params.from,
|
|
72
|
+
dmSenderId: params.from,
|
|
73
|
+
});
|
|
74
|
+
const { senderAccess } = access;
|
|
75
|
+
if (params.group && senderAccess.decision !== "allow") {
|
|
76
|
+
if (senderAccess.reasonCode === "group_policy_disabled") {
|
|
77
|
+
logWhatsAppVerbose(params.verbose, "Blocked group message (groupPolicy: disabled)");
|
|
78
|
+
} else if (senderAccess.reasonCode === "group_policy_empty_allowlist") {
|
|
79
|
+
logWhatsAppVerbose(
|
|
80
|
+
params.verbose,
|
|
81
|
+
"Blocked group message (groupPolicy: allowlist, no groupAllowFrom)",
|
|
82
|
+
);
|
|
83
|
+
} else {
|
|
84
|
+
logWhatsAppVerbose(
|
|
85
|
+
params.verbose,
|
|
86
|
+
`Blocked group message from ${params.senderE164 ?? "unknown sender"} (groupPolicy: allowlist)`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
allowed: false,
|
|
91
|
+
shouldMarkRead: false,
|
|
92
|
+
isSelfChat: policy.isSelfChat,
|
|
93
|
+
resolvedAccountId: policy.account.accountId,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// DM access control (secure defaults): "pairing" (default) / "allowlist" / "open" / "disabled".
|
|
98
|
+
if (!params.group) {
|
|
99
|
+
if (params.isFromMe && !policy.isSamePhone(params.from)) {
|
|
100
|
+
logWhatsAppVerbose(params.verbose, "Skipping outbound DM (fromMe); no pairing reply needed.");
|
|
101
|
+
return {
|
|
102
|
+
allowed: false,
|
|
103
|
+
shouldMarkRead: false,
|
|
104
|
+
isSelfChat: policy.isSelfChat,
|
|
105
|
+
resolvedAccountId: policy.account.accountId,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
if (senderAccess.decision === "block" && senderAccess.reasonCode === "dm_policy_disabled") {
|
|
109
|
+
logWhatsAppVerbose(params.verbose, "Blocked dm (dmPolicy: disabled)");
|
|
110
|
+
return {
|
|
111
|
+
allowed: false,
|
|
112
|
+
shouldMarkRead: false,
|
|
113
|
+
isSelfChat: policy.isSelfChat,
|
|
114
|
+
resolvedAccountId: policy.account.accountId,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
if (senderAccess.decision === "pairing" && !policy.isSamePhone(params.from)) {
|
|
118
|
+
const candidate = params.from;
|
|
119
|
+
if (suppressPairingReply) {
|
|
120
|
+
logWhatsAppVerbose(
|
|
121
|
+
params.verbose,
|
|
122
|
+
`Skipping pairing reply for historical DM from ${candidate}.`,
|
|
123
|
+
);
|
|
124
|
+
} else {
|
|
125
|
+
await createChannelPairingChallengeIssuer({
|
|
126
|
+
channel: "whatsapp",
|
|
127
|
+
upsertPairingRequest: async ({ id, meta }) =>
|
|
128
|
+
await upsertChannelPairingRequest({
|
|
129
|
+
channel: "whatsapp",
|
|
130
|
+
id,
|
|
131
|
+
accountId: policy.account.accountId,
|
|
132
|
+
meta,
|
|
133
|
+
}),
|
|
134
|
+
})({
|
|
135
|
+
senderId: candidate,
|
|
136
|
+
senderIdLine: `Your WhatsApp phone number: ${candidate}`,
|
|
137
|
+
meta: { name: (params.pushName ?? "").trim() || undefined },
|
|
138
|
+
onCreated: () => {
|
|
139
|
+
logWhatsAppVerbose(
|
|
140
|
+
params.verbose,
|
|
141
|
+
`whatsapp pairing request sender=${candidate} name=${params.pushName ?? "unknown"}`,
|
|
142
|
+
);
|
|
143
|
+
},
|
|
144
|
+
sendPairingReply: async (text) => {
|
|
145
|
+
await params.sock.sendMessage(params.remoteJid, { text });
|
|
146
|
+
},
|
|
147
|
+
onReplyError: (err) => {
|
|
148
|
+
logWhatsAppVerbose(
|
|
149
|
+
params.verbose,
|
|
150
|
+
`whatsapp pairing reply failed for ${candidate}: ${String(err)}`,
|
|
151
|
+
);
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
allowed: false,
|
|
157
|
+
shouldMarkRead: false,
|
|
158
|
+
isSelfChat: policy.isSelfChat,
|
|
159
|
+
resolvedAccountId: policy.account.accountId,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
if (senderAccess.decision !== "allow") {
|
|
163
|
+
logWhatsAppVerbose(
|
|
164
|
+
params.verbose,
|
|
165
|
+
`Blocked unauthorized sender ${params.from} (dmPolicy=${policy.dmPolicy})`,
|
|
166
|
+
);
|
|
167
|
+
return {
|
|
168
|
+
allowed: false,
|
|
169
|
+
shouldMarkRead: false,
|
|
170
|
+
isSelfChat: policy.isSelfChat,
|
|
171
|
+
resolvedAccountId: policy.account.accountId,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
allowed: true,
|
|
178
|
+
shouldMarkRead: true,
|
|
179
|
+
isSelfChat: policy.isSelfChat,
|
|
180
|
+
resolvedAccountId: policy.account.accountId,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export const testing = {
|
|
185
|
+
resolveWhatsAppInboundPolicy,
|
|
186
|
+
};
|
|
187
|
+
export { testing as __testing };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { createClaimableDedupe } from "autobot/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
|
+
}
|