feat(channels): add bluebubbles imessage adapter
This commit is contained in:
@@ -33,6 +33,7 @@ function makeBaseConfig(): Config {
|
||||
signal: undefined,
|
||||
teams: undefined,
|
||||
google_chat: undefined,
|
||||
bluebubbles: undefined,
|
||||
} as unknown as Config;
|
||||
}
|
||||
|
||||
@@ -49,6 +50,7 @@ describe('discoverServices', () => {
|
||||
expect.objectContaining({ name: 'signal', status: 'not_configured' }),
|
||||
expect.objectContaining({ name: 'teams', status: 'not_configured' }),
|
||||
expect.objectContaining({ name: 'google_chat', status: 'not_configured' }),
|
||||
expect.objectContaining({ name: 'bluebubbles', status: 'not_configured' }),
|
||||
expect.objectContaining({ name: 'cron', status: 'not_configured' }),
|
||||
expect.objectContaining({ name: 'mcp', status: 'not_configured' }),
|
||||
expect.objectContaining({ name: 'web_search', status: 'configured' }),
|
||||
|
||||
@@ -56,6 +56,7 @@ export function discoverServices(
|
||||
{ key: 'signal', name: 'signal', description: 'Signal bot (signal-cli)' },
|
||||
{ key: 'teams', name: 'teams', description: 'Microsoft Teams bot' },
|
||||
{ key: 'google_chat', name: 'google_chat', description: 'Google Chat bot' },
|
||||
{ key: 'bluebubbles', name: 'bluebubbles', description: 'iMessage via BlueBubbles' },
|
||||
];
|
||||
|
||||
for (const { key, name, description } of channelConfigs) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user