Skip to content

Commit 0e825ec

Browse files
committed
test: add Feishu bot-menu lifecycle regression
1 parent 7f52a8a commit 0e825ec

File tree

3 files changed

+413
-53
lines changed

3 files changed

+413
-53
lines changed

extensions/feishu/src/monitor.account.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,15 @@ function registerEventHandlers(
544544
}),
545545
},
546546
};
547+
const syntheticMessageId = syntheticEvent.message.message_id;
548+
if (await hasProcessedFeishuMessage(syntheticMessageId, accountId, log)) {
549+
log(`feishu[${accountId}]: dropping duplicate bot-menu event for ${syntheticMessageId}`);
550+
return;
551+
}
552+
if (!tryBeginFeishuMessageProcessing(syntheticMessageId, accountId)) {
553+
log(`feishu[${accountId}]: dropping in-flight bot-menu event for ${syntheticMessageId}`);
554+
return;
555+
}
547556
const handleLegacyMenu = () =>
548557
handleFeishuMessage({
549558
cfg,
@@ -553,6 +562,7 @@ function registerEventHandlers(
553562
runtime,
554563
chatHistories,
555564
accountId,
565+
processingClaimHeld: true,
556566
});
557567

558568
const promise = maybeHandleFeishuQuickActionMenu({
@@ -561,12 +571,19 @@ function registerEventHandlers(
561571
operatorOpenId,
562572
runtime,
563573
accountId,
564-
}).then((handledMenu) => {
565-
if (handledMenu) {
566-
return;
567-
}
568-
return handleLegacyMenu();
569-
});
574+
})
575+
.then(async (handledMenu) => {
576+
if (handledMenu) {
577+
await recordProcessedFeishuMessage(syntheticMessageId, accountId, log);
578+
releaseFeishuMessageProcessing(syntheticMessageId, accountId);
579+
return;
580+
}
581+
return await handleLegacyMenu();
582+
})
583+
.catch((err) => {
584+
releaseFeishuMessageProcessing(syntheticMessageId, accountId);
585+
throw err;
586+
});
570587
if (fireAndForget) {
571588
promise.catch((err) => {
572589
error(`feishu[${accountId}]: error handling bot menu event: ${String(err)}`);

0 commit comments

Comments
 (0)