Add Zalo channel adapter with webhook and send path
This commit is contained in:
@@ -53,6 +53,7 @@ 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';
|
||||
import type { ZaloAdapter } from '../channels/zalo/adapter.js';
|
||||
|
||||
export interface GatewayServerConfig {
|
||||
port: number;
|
||||
@@ -126,6 +127,8 @@ export interface GatewayServerConfig {
|
||||
lineHandler?: Pick<LineAdapter, 'handleRequest'>;
|
||||
/** Optional Feishu adapter for inbound webhook events. */
|
||||
feishuHandler?: Pick<FeishuAdapter, 'handleRequest'>;
|
||||
/** Optional Zalo adapter for inbound webhook events. */
|
||||
zaloHandler?: Pick<ZaloAdapter, 'handleRequest'>;
|
||||
}
|
||||
|
||||
export class GatewayServer {
|
||||
@@ -742,6 +745,12 @@ export class GatewayServer {
|
||||
return;
|
||||
}
|
||||
|
||||
// Zalo events route — bypass gateway auth (Zalo webhook posts directly)
|
||||
if (this.config.zaloHandler && req.method === 'POST' && req.url?.startsWith('/zalo/events')) {
|
||||
await this.config.zaloHandler.handleRequest(req, res);
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply auth to HTTP requests when configured
|
||||
const authConfig = this.config.auth ?? {};
|
||||
if (this.config.authHttp !== false && authConfig.token) {
|
||||
@@ -870,6 +879,11 @@ export class GatewayServer {
|
||||
this.config.feishuHandler = handler;
|
||||
}
|
||||
|
||||
/** Set the Zalo handler for inbound webhook HTTP routes (late binding). */
|
||||
setZaloHandler(handler: Pick<ZaloAdapter, 'handleRequest'>): void {
|
||||
this.config.zaloHandler = 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