forked from bai/curriculum-project-hub
fix: ack Feishu card actions before interrupt work
This commit is contained in:
@@ -294,7 +294,7 @@ export async function sendCard(rt: FeishuRuntime, chatId: string, card: Record<s
|
||||
}
|
||||
|
||||
/** Patch an interactive card in-place with raw JSON. */
|
||||
export async function patchCard(rt: FeishuRuntime, messageId: string, card: Record<string, unknown>): Promise<void> {
|
||||
export async function patchCard(rt: FeishuRuntime, messageId: string, card: Record<string, unknown>): Promise<boolean> {
|
||||
const client = rt.client as unknown as {
|
||||
im: { v1: { message: { patch: (p: unknown) => Promise<unknown> } } };
|
||||
};
|
||||
@@ -304,8 +304,10 @@ export async function patchCard(rt: FeishuRuntime, messageId: string, card: Reco
|
||||
params: { msg_type: "interactive" },
|
||||
data: { content: JSON.stringify(card) },
|
||||
});
|
||||
return true;
|
||||
} catch (e) {
|
||||
rt.logger.warn({ messageId, err: e instanceof Error ? e.message : String(e) }, "patchCard failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -831,8 +833,9 @@ export function startFeishuListenerWithClient(
|
||||
};
|
||||
if (onCardAction !== undefined) {
|
||||
handlers["card.action.trigger"] = async (data) => {
|
||||
try { await onCardAction(data as CardActionEvent, rt); }
|
||||
catch (e) { logger.error({ err: e }, "feishu card action handler threw"); }
|
||||
void Promise.resolve()
|
||||
.then(() => onCardAction(data as CardActionEvent, rt))
|
||||
.catch((e) => { logger.error({ err: e }, "feishu card action handler threw"); });
|
||||
};
|
||||
}
|
||||
void wsClient.start({ eventDispatcher: new lark.EventDispatcher({}).register(handlers) });
|
||||
|
||||
Reference in New Issue
Block a user