feat(channels): add mattermost adapter and wiring
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { configSchema } from '../config/schema.js';
|
||||
import { ChannelRegistry } from '../channels/index.js';
|
||||
import { HookEngine } from '../hooks/index.js';
|
||||
import { registerChannels } from './channels.js';
|
||||
|
||||
describe('registerChannels', () => {
|
||||
it('registers Mattermost adapter when configured', () => {
|
||||
const config = configSchema.parse({
|
||||
telegram: { bot_token: 'test-token', allowed_chat_ids: [1] },
|
||||
models: { default: { provider: 'anthropic', model: 'claude-3' } },
|
||||
mattermost: {
|
||||
server_url: 'https://mattermost.example.com',
|
||||
bot_token: 'mm-token',
|
||||
allowed_channel_ids: ['chan-1'],
|
||||
},
|
||||
});
|
||||
|
||||
const channelRegistry = new ChannelRegistry();
|
||||
const gateway = {
|
||||
setWebhookHandler: vi.fn(),
|
||||
setGmailHandler: vi.fn(),
|
||||
setTeamsHandler: vi.fn(),
|
||||
setGoogleChatHandler: vi.fn(),
|
||||
setBlueBubblesHandler: vi.fn(),
|
||||
};
|
||||
|
||||
registerChannels({
|
||||
config,
|
||||
channelRegistry,
|
||||
hookEngine: new HookEngine(config.hooks),
|
||||
gateway: gateway as unknown as Parameters<typeof registerChannels>[0]['gateway'],
|
||||
});
|
||||
|
||||
const names = channelRegistry.list().map((adapter) => adapter.name);
|
||||
expect(names).toContain('mattermost');
|
||||
expect(names).toContain('webchat');
|
||||
});
|
||||
});
|
||||
+15
-1
@@ -1,6 +1,6 @@
|
||||
import type { Config } from '../config/index.js';
|
||||
import type { HookEngine } from '../hooks/index.js';
|
||||
import { ChannelRegistry, TelegramAdapter, WebChatAdapter, DiscordAdapter, SlackAdapter, WhatsAppAdapter, MatrixAdapter, SignalAdapter, TeamsAdapter, GoogleChatAdapter, BlueBubblesAdapter, PairingManager } from '../channels/index.js';
|
||||
import { ChannelRegistry, TelegramAdapter, WebChatAdapter, DiscordAdapter, SlackAdapter, WhatsAppAdapter, MatrixAdapter, SignalAdapter, MattermostAdapter, TeamsAdapter, GoogleChatAdapter, BlueBubblesAdapter, PairingManager } from '../channels/index.js';
|
||||
import { CronScheduler, WebhookHandler, GmailWatcher } from '../automation/index.js';
|
||||
import type { GatewayServer } from '../gateway/index.js';
|
||||
|
||||
@@ -101,6 +101,20 @@ export function registerChannels(deps: ChannelsDeps): ChannelsResult {
|
||||
channelRegistry.register(signalAdapter);
|
||||
}
|
||||
|
||||
// Register Mattermost adapter (if configured)
|
||||
if (config.mattermost) {
|
||||
const mattermostAdapter = new MattermostAdapter({
|
||||
serverUrl: config.mattermost.server_url,
|
||||
botToken: config.mattermost.bot_token,
|
||||
allowedChannelIds: config.mattermost.allowed_channel_ids.length > 0 ? config.mattermost.allowed_channel_ids : undefined,
|
||||
requireMention: config.mattermost.require_mention,
|
||||
mentionName: config.mattermost.mention_name,
|
||||
pollIntervalMs: config.mattermost.poll_interval_ms,
|
||||
pairingManager,
|
||||
});
|
||||
channelRegistry.register(mattermostAdapter);
|
||||
}
|
||||
|
||||
// Register Microsoft Teams adapter (if configured)
|
||||
if (config.teams) {
|
||||
const teamsAdapter = new TeamsAdapter({
|
||||
|
||||
Reference in New Issue
Block a user