惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
Google DeepMind News
Google DeepMind News
Apple Machine Learning Research
Apple Machine Learning Research
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
爱范儿
爱范儿
L
LangChain Blog
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
MongoDB | Blog
MongoDB | Blog
Hugging Face - Blog
Hugging Face - Blog
G
Google Developers Blog
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
博客园 - 三生石上(FineUI控件)
D
DataBreaches.Net
Recent Announcements
Recent Announcements
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
refactor(whatsapp): add inbound admission envelope · open...
mcaxtr · 2026-06-16 · via Recent Commits to openclaw:main

@@ -5,14 +5,28 @@ import { upsertChannelPairingRequest } from "openclaw/plugin-sdk/conversation-ru

55

import { defaultRuntime } from "openclaw/plugin-sdk/runtime-env";

66

import { warnMissingProviderGroupPolicyFallbackOnce } from "openclaw/plugin-sdk/runtime-group-policy";

77

import { resolveWhatsAppInboundPolicy, resolveWhatsAppIngressAccess } from "../inbound-policy.js";

8+

import { buildWhatsAppInboundAdmission, type WhatsAppInboundAdmission } from "./admission.js";

899-

export type InboundAccessControlResult = {

10-

allowed: boolean;

11-

shouldMarkRead: boolean;

10+

export type BlockedInboundAccessControlResult = {

11+

allowed: false;

12+

shouldMarkRead: false;

1213

isSelfChat: boolean;

1314

resolvedAccountId: string;

15+

admission?: never;

1416

};

151718+

export type AcceptedInboundAccessControlResult = {

19+

allowed: true;

20+

shouldMarkRead: true;

21+

isSelfChat: boolean;

22+

resolvedAccountId: string;

23+

admission: WhatsAppInboundAdmission;

24+

};

25+26+

export type InboundAccessControlResult =

27+

| BlockedInboundAccessControlResult

28+

| AcceptedInboundAccessControlResult;

29+1630

const PAIRING_REPLY_HISTORY_GRACE_MS = 30_000;

17311832

function logWhatsAppVerbose(enabled: boolean | undefined, message: string) {

@@ -22,12 +36,24 @@ function logWhatsAppVerbose(enabled: boolean | undefined, message: string) {

2236

defaultRuntime.log(message);

2337

}

243839+

function blockedInboundAccess(

40+

policy: ReturnType<typeof resolveWhatsAppInboundPolicy>,

41+

): BlockedInboundAccessControlResult {

42+

return {

43+

allowed: false,

44+

shouldMarkRead: false,

45+

isSelfChat: policy.isSelfChat,

46+

resolvedAccountId: policy.account.accountId,

47+

};

48+

}

49+2550

export async function checkInboundAccessControl(params: {

2651

cfg: OpenClawConfig;

2752

accountId: string;

2853

from: string;

2954

selfE164: string | null;

3055

senderE164: string | null;

56+

senderJid?: string | null;

3157

group: boolean;

3258

pushName?: string;

3359

isFromMe: boolean;

@@ -64,12 +90,17 @@ export async function checkInboundAccessControl(params: {

6490

accountId: policy.account.accountId,

6591

log: (message) => logWhatsAppVerbose(params.verbose, message),

6692

});

93+

const conversationId = params.group ? params.remoteJid : params.from;

94+

const accessSenderId = params.group ? params.senderE164 : params.from;

95+

const admissionSenderId = params.group

96+

? (params.senderE164 ?? params.senderJid ?? params.from)

97+

: params.from;

6798

const access = await resolveWhatsAppIngressAccess({

6899

cfg: params.cfg,

69100

policy,

70101

isGroup: params.group,

71-

conversationId: params.remoteJid,

72-

senderId: params.group ? params.senderE164 : params.from,

102+

conversationId,

103+

senderId: accessSenderId,

73104

dmSenderId: params.from,

74105

});

75106

const { senderAccess } = access;

@@ -87,33 +118,18 @@ export async function checkInboundAccessControl(params: {

87118

`Blocked group message from ${params.senderE164 ?? "unknown sender"} (groupPolicy: allowlist)`,

88119

);

89120

}

90-

return {

91-

allowed: false,

92-

shouldMarkRead: false,

93-

isSelfChat: policy.isSelfChat,

94-

resolvedAccountId: policy.account.accountId,

95-

};

121+

return blockedInboundAccess(policy);

96122

}

9712398124

// DM access control (secure defaults): "pairing" (default) / "allowlist" / "open" / "disabled".

99125

if (!params.group) {

100126

if (params.isFromMe && !policy.isSamePhone(params.from)) {

101127

logWhatsAppVerbose(params.verbose, "Skipping outbound DM (fromMe); no pairing reply needed.");

102-

return {

103-

allowed: false,

104-

shouldMarkRead: false,

105-

isSelfChat: policy.isSelfChat,

106-

resolvedAccountId: policy.account.accountId,

107-

};

128+

return blockedInboundAccess(policy);

108129

}

109130

if (senderAccess.decision === "block" && senderAccess.reasonCode === "dm_policy_disabled") {

110131

logWhatsAppVerbose(params.verbose, "Blocked dm (dmPolicy: disabled)");

111-

return {

112-

allowed: false,

113-

shouldMarkRead: false,

114-

isSelfChat: policy.isSelfChat,

115-

resolvedAccountId: policy.account.accountId,

116-

};

132+

return blockedInboundAccess(policy);

117133

}

118134

if (senderAccess.decision === "pairing" && !policy.isSamePhone(params.from)) {

119135

const candidate = params.from;

@@ -153,24 +169,14 @@ export async function checkInboundAccessControl(params: {

153169

},

154170

});

155171

}

156-

return {

157-

allowed: false,

158-

shouldMarkRead: false,

159-

isSelfChat: policy.isSelfChat,

160-

resolvedAccountId: policy.account.accountId,

161-

};

172+

return blockedInboundAccess(policy);

162173

}

163174

if (senderAccess.decision !== "allow") {

164175

logWhatsAppVerbose(

165176

params.verbose,

166177

`Blocked unauthorized sender ${params.from} (dmPolicy=${policy.dmPolicy})`,

167178

);

168-

return {

169-

allowed: false,

170-

shouldMarkRead: false,

171-

isSelfChat: policy.isSelfChat,

172-

resolvedAccountId: policy.account.accountId,

173-

};

179+

return blockedInboundAccess(policy);

174180

}

175181

}

176182

@@ -179,6 +185,14 @@ export async function checkInboundAccessControl(params: {

179185

shouldMarkRead: true,

180186

isSelfChat: policy.isSelfChat,

181187

resolvedAccountId: policy.account.accountId,

188+

admission: buildWhatsAppInboundAdmission({

189+

policy,

190+

access,

191+

isGroup: params.group,

192+

conversationId,

193+

senderId: admissionSenderId,

194+

dmSenderId: params.from,

195+

}),

182196

};

183197

}

184198