fix(feishu): WSClient appId + EventDispatcher pattern

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-09 03:45:02 -07:00
parent 042e49988c
commit bbcf1d742d
1 changed files with 4 additions and 2 deletions

View File

@ -127,12 +127,12 @@ export class FeishuRouterService implements OnModuleInit, OnModuleDestroy {
// WebSocket long-connection client — SDK handles auth, reconnect, ping/pong, ACK
this.wsClient = new lark.WSClient({
appID: this.appId,
appId: this.appId,
appSecret: this.appSecret,
loggerLevel: lark.LoggerLevel.warn,
});
this.wsClient.start({
const dispatcher = new lark.EventDispatcher({}).register({
'im.message.receive_v1': async (data: any) => {
try {
await this.handleIncomingEvent(data);
@ -142,6 +142,8 @@ export class FeishuRouterService implements OnModuleInit, OnModuleDestroy {
},
});
this.wsClient.start({ eventDispatcher: dispatcher });
this.cleanupTimer = setInterval(() => this.periodicCleanup(), CLEANUP_INTERVAL_MS);
if (this.cleanupTimer.unref) this.cleanupTimer.unref();