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

推荐订阅源

IT之家
IT之家
博客园 - 聂微东
雷峰网
雷峰网
Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
Hugging Face - Blog
Hugging Face - Blog
S
SegmentFault 最新的问题
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
博客园 - 司徒正美
爱范儿
爱范儿
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
博客园 - 【当耐特】
Jina AI
Jina AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
酷 壳 – CoolShell
酷 壳 – CoolShell
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
人人都是产品经理
人人都是产品经理
V
V2EX

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
fix(whatsapp): persist inbound delivery in plugin state (...
steipete · 2026-05-23 · via Recent Commits to openclaw:main

@@ -0,0 +1,79 @@

1+

import { createHash } from "node:crypto";

2+

import type { WAMessage } from "baileys";

3+

import { createDurableInboundReceiveJournal } from "openclaw/plugin-sdk/channel-message";

4+

import type { PluginJsonValue } from "openclaw/plugin-sdk/plugin-entry";

5+

import { getWhatsAppRuntime } from "../runtime.js";

6+

import { BufferJSON } from "../session.runtime.js";

7+8+

const WHATSAPP_DURABLE_INBOUND_PENDING_MAX_ENTRIES = 450;

9+

const WHATSAPP_DURABLE_INBOUND_COMPLETED_MAX_ENTRIES = 450;

10+

const WHATSAPP_DURABLE_INBOUND_PENDING_TTL_MS = 30 * 24 * 60 * 60 * 1000;

11+

const WHATSAPP_DURABLE_INBOUND_COMPLETED_TTL_MS = 7 * 24 * 60 * 60 * 1000;

12+13+

export type WhatsAppReadReceiptTarget = {

14+

remoteJid: string;

15+

id: string;

16+

participant?: string;

17+

};

18+19+

export type SerializedWhatsAppDurableInboundMessage = PluginJsonValue;

20+21+

export type WhatsAppDurableInboundPayload = {

22+

message: SerializedWhatsAppDurableInboundMessage;

23+

upsertType?: string;

24+

receivedAt: number;

25+

};

26+27+

export type WhatsAppDurableInboundMetadata = {

28+

readReceipt?: WhatsAppReadReceiptTarget;

29+

};

30+31+

export type WhatsAppDurableInboundCompletedMetadata = {

32+

readReceipt?: WhatsAppReadReceiptTarget;

33+

};

34+35+

function hashNamespacePart(value: string): string {

36+

return createHash("sha256").update(value).digest("hex").slice(0, 24);

37+

}

38+39+

export function createWhatsAppDurableInboundMessageId(params: {

40+

remoteJid: string;

41+

id: string;

42+

}): string {

43+

return createHash("sha256").update(`${params.remoteJid}\n${params.id}`).digest("hex");

44+

}

45+46+

export function serializeWhatsAppDurableInboundMessage(

47+

message: WAMessage,

48+

): SerializedWhatsAppDurableInboundMessage {

49+

return JSON.parse(JSON.stringify(message, BufferJSON.replacer)) as PluginJsonValue;

50+

}

51+52+

export function deserializeWhatsAppDurableInboundMessage(

53+

message: SerializedWhatsAppDurableInboundMessage,

54+

): WAMessage {

55+

return JSON.parse(JSON.stringify(message), BufferJSON.reviver) as WAMessage;

56+

}

57+58+

export function createWhatsAppDurableInboundReceiveJournal(accountId: string) {

59+

const runtime = getWhatsAppRuntime();

60+

const accountPart = hashNamespacePart(accountId);

61+

return createDurableInboundReceiveJournal<

62+

WhatsAppDurableInboundPayload,

63+

WhatsAppDurableInboundMetadata,

64+

WhatsAppDurableInboundCompletedMetadata

65+

>({

66+

pendingStore: runtime.state.openKeyedStore({

67+

namespace: `inbound.v1.pending.${accountPart}`,

68+

maxEntries: WHATSAPP_DURABLE_INBOUND_PENDING_MAX_ENTRIES,

69+

defaultTtlMs: WHATSAPP_DURABLE_INBOUND_PENDING_TTL_MS,

70+

}),

71+

completedStore: runtime.state.openKeyedStore({

72+

namespace: `inbound.v1.completed.${accountPart}`,

73+

maxEntries: WHATSAPP_DURABLE_INBOUND_COMPLETED_MAX_ENTRIES,

74+

defaultTtlMs: WHATSAPP_DURABLE_INBOUND_COMPLETED_TTL_MS,

75+

}),

76+

pendingTtlMs: WHATSAPP_DURABLE_INBOUND_PENDING_TTL_MS,

77+

completedTtlMs: WHATSAPP_DURABLE_INBOUND_COMPLETED_TTL_MS,

78+

});

79+

}