feat(channels): add bluebubbles imessage adapter

This commit is contained in:
William Valentin
2026-02-16 09:41:26 -08:00
parent 2cadff901d
commit 8e9f9aa4de
13 changed files with 409 additions and 2 deletions
+14
View File
@@ -45,6 +45,7 @@ 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';
import type { BlueBubblesAdapter } from '../channels/bluebubbles/adapter.js';
export interface GatewayServerConfig {
port: number;
@@ -99,6 +100,8 @@ export interface GatewayServerConfig {
teamsHandler?: Pick<TeamsAdapter, 'handleRequest'>;
/** Optional Google Chat adapter for inbound Chat event webhooks. */
googleChatHandler?: Pick<GoogleChatAdapter, 'handleRequest'>;
/** Optional BlueBubbles adapter for inbound iMessage event webhooks. */
blueBubblesHandler?: Pick<BlueBubblesAdapter, 'handleRequest'>;
}
export class GatewayServer {
@@ -494,6 +497,12 @@ export class GatewayServer {
return;
}
// BlueBubbles events route — bypass gateway auth (BlueBubbles webhook posts directly)
if (this.config.blueBubblesHandler && req.method === 'POST' && req.url?.startsWith('/bluebubbles/events')) {
await this.config.blueBubblesHandler.handleRequest(req, res);
return;
}
// Apply auth to HTTP requests when configured
const authConfig = this.config.auth ?? {};
if (this.config.authHttp !== false && authConfig.token) {
@@ -591,6 +600,11 @@ export class GatewayServer {
this.config.googleChatHandler = handler;
}
/** Set the BlueBubbles handler for inbound webhook HTTP routes (late binding). */
setBlueBubblesHandler(handler: Pick<BlueBubblesAdapter, 'handleRequest'>): void {
this.config.blueBubblesHandler = handler;
}
private async startDiscovery(host: string, port: number): Promise<void> {
const discovery = this.config.discovery;
if (!discovery?.enabled) {