Add Feishu channel adapter with webhook and send path
This commit is contained in:
@@ -52,6 +52,7 @@ import type { TeamsAdapter } from '../channels/teams/adapter.js';
|
||||
import type { GoogleChatAdapter } from '../channels/googleChat/adapter.js';
|
||||
import type { BlueBubblesAdapter } from '../channels/bluebubbles/adapter.js';
|
||||
import type { LineAdapter } from '../channels/line/adapter.js';
|
||||
import type { FeishuAdapter } from '../channels/feishu/adapter.js';
|
||||
|
||||
export interface GatewayServerConfig {
|
||||
port: number;
|
||||
@@ -123,6 +124,8 @@ export interface GatewayServerConfig {
|
||||
blueBubblesHandler?: Pick<BlueBubblesAdapter, 'handleRequest'>;
|
||||
/** Optional LINE adapter for inbound webhook events. */
|
||||
lineHandler?: Pick<LineAdapter, 'handleRequest'>;
|
||||
/** Optional Feishu adapter for inbound webhook events. */
|
||||
feishuHandler?: Pick<FeishuAdapter, 'handleRequest'>;
|
||||
}
|
||||
|
||||
export class GatewayServer {
|
||||
@@ -733,6 +736,12 @@ export class GatewayServer {
|
||||
return;
|
||||
}
|
||||
|
||||
// Feishu events route — bypass gateway auth (Feishu webhook posts directly)
|
||||
if (this.config.feishuHandler && req.method === 'POST' && req.url?.startsWith('/feishu/events')) {
|
||||
await this.config.feishuHandler.handleRequest(req, res);
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply auth to HTTP requests when configured
|
||||
const authConfig = this.config.auth ?? {};
|
||||
if (this.config.authHttp !== false && authConfig.token) {
|
||||
@@ -856,6 +865,11 @@ export class GatewayServer {
|
||||
this.config.lineHandler = handler;
|
||||
}
|
||||
|
||||
/** Set the Feishu handler for inbound webhook HTTP routes (late binding). */
|
||||
setFeishuHandler(handler: Pick<FeishuAdapter, 'handleRequest'>): void {
|
||||
this.config.feishuHandler = handler;
|
||||
}
|
||||
|
||||
private async startDiscovery(host: string, port: number): Promise<void> {
|
||||
const discovery = this.config.discovery;
|
||||
if (!discovery?.enabled) {
|
||||
|
||||
Reference in New Issue
Block a user