feat: polish group binding

Signed-off-by: d0zingcat <iamtangli42@gmail.com>
This commit is contained in:
2026-01-14 17:29:50 +08:00
parent 75306a67b1
commit ee67cefb4d
8 changed files with 32 additions and 12 deletions

View File

@@ -31,11 +31,11 @@ feishuEvent.post('/', async (c) => {
}
// 2. Dispatch event
// The dispatcher expects an object containing headers and body
const result = await eventDispatcher.invoke({
...req.body,
headers: req.headers
});
// The dispatcher expects an object containing headers and body.
// We use Object.create to put headers on the prototype so they are accessible
// but not included in JSON.stringify, which preserves signature verification.
const payload = Object.assign(Object.create({ headers: headerRecord }), body);
const result = await eventDispatcher.invoke(payload);
return c.json(result || {});
} catch (e) {

View File

@@ -4,7 +4,10 @@ import { eq } from 'drizzle-orm';
import * as lark from '@larksuiteoapi/node-sdk';
import { logger } from './lib/logger';
export const eventDispatcher = new lark.EventDispatcher({}).register({
export const eventDispatcher = new lark.EventDispatcher({
encryptKey: process.env.FEISHU_ENCRYPT_KEY,
verificationToken: process.env.FEISHU_VERIFICATION_TOKEN,
}).register({
'im.chat.member.bot.added_v1': async (data) => {
const { chat_id, name } = data as any;
logger.info({ chat_id, name }, '[Feishu Event] Bot added to group');