@yaoyuanchao/dingtalk 1.7.3 → 1.7.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/monitor.ts +13 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yaoyuanchao/dingtalk",
3
- "version": "1.7.3",
3
+ "version": "1.7.4",
4
4
  "type": "module",
5
5
  "description": "DingTalk channel plugin for ClawdBot/OpenClaw with Stream Mode support",
6
6
  "license": "MIT",
package/src/monitor.ts CHANGED
@@ -308,8 +308,11 @@ export async function startDingTalkMonitor(ctx: DingTalkMonitorContext): Promise
308
308
  touchActivity(); // Track message activity for heartbeat
309
309
 
310
310
  // Deduplication: skip messages already processed (e.g. re-delivered after reconnect)
311
+ // Check both protocol-level messageId AND business-level msgId, because
312
+ // DingTalk re-delivers with a NEW protocol messageId after reconnect but
313
+ // the same business msgId.
311
314
  if (isDuplicateMessage(protocolMsgId)) {
312
- log?.info?.("[dingtalk] Duplicate message skipped: " + protocolMsgId);
315
+ log?.info?.("[dingtalk] Duplicate message skipped (protocol): " + protocolMsgId);
313
316
  return { status: "SUCCESS", message: "OK" };
314
317
  }
315
318
  markMessageProcessed(protocolMsgId);
@@ -317,6 +320,15 @@ export async function startDingTalkMonitor(ctx: DingTalkMonitorContext): Promise
317
320
  try {
318
321
  const data: DingTalkRobotMessage = typeof downstream.data === "string"
319
322
  ? JSON.parse(downstream.data) : downstream.data;
323
+
324
+ // Business-level dedup: same msgId re-delivered with different protocol ID
325
+ const bizMsgId = data.msgId;
326
+ if (bizMsgId && isDuplicateMessage('biz:' + bizMsgId)) {
327
+ log?.info?.("[dingtalk] Duplicate message skipped (bizMsgId): " + bizMsgId);
328
+ return { status: "SUCCESS", message: "OK" };
329
+ }
330
+ if (bizMsgId) markMessageProcessed('biz:' + bizMsgId);
331
+
320
332
  setStatus?.({ lastInboundAt: Date.now() });
321
333
  await processInboundMessage(data, ctx);
322
334
  } catch (err) {