mirror of
https://github.com/d0zingcat/alert-message-center.git
synced 2026-05-13 15:09:19 +00:00
feat: polish group binding
Signed-off-by: d0zingcat <iamtangli42@gmail.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user