feat(channels): add google chat adapter and webhook route
This commit is contained in:
@@ -44,6 +44,7 @@ import type { RoutingPolicy } from '../routing/index.js';
|
||||
import type { ChannelRegistry } from '../channels/index.js';
|
||||
import { RequestBodyTooLargeError, readRequestBody } from '../utils/httpBody.js';
|
||||
import type { TeamsAdapter } from '../channels/teams/adapter.js';
|
||||
import type { GoogleChatAdapter } from '../channels/googleChat/adapter.js';
|
||||
|
||||
export interface GatewayServerConfig {
|
||||
port: number;
|
||||
@@ -96,6 +97,8 @@ export interface GatewayServerConfig {
|
||||
};
|
||||
/** Optional Teams adapter for inbound Bot Framework activity webhooks. */
|
||||
teamsHandler?: Pick<TeamsAdapter, 'handleRequest'>;
|
||||
/** Optional Google Chat adapter for inbound Chat event webhooks. */
|
||||
googleChatHandler?: Pick<GoogleChatAdapter, 'handleRequest'>;
|
||||
}
|
||||
|
||||
export class GatewayServer {
|
||||
@@ -485,6 +488,12 @@ export class GatewayServer {
|
||||
return;
|
||||
}
|
||||
|
||||
// Google Chat events route — bypass gateway auth (Google Chat posts directly)
|
||||
if (this.config.googleChatHandler && req.method === 'POST' && req.url?.startsWith('/google-chat/events')) {
|
||||
await this.config.googleChatHandler.handleRequest(req, res);
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply auth to HTTP requests when configured
|
||||
const authConfig = this.config.auth ?? {};
|
||||
if (this.config.authHttp !== false && authConfig.token) {
|
||||
@@ -577,6 +586,11 @@ export class GatewayServer {
|
||||
this.config.teamsHandler = handler;
|
||||
}
|
||||
|
||||
/** Set the Google Chat handler for inbound event HTTP routes (late binding). */
|
||||
setGoogleChatHandler(handler: Pick<GoogleChatAdapter, 'handleRequest'>): void {
|
||||
this.config.googleChatHandler = 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