fix(gateway): wire Telegram plugin into gateway plugin host
Some checks failed
ci/woodpecker/push/ci Pipeline failed
Some checks failed
ci/woodpecker/push/ci Pipeline failed
Add @mosaic/telegram-plugin dependency to gateway, implement TelegramChannelPluginAdapter, replace stub warning with real plugin instantiation, and document all Phase 5 env vars in .env.example. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
14
.env.example
14
.env.example
@@ -18,3 +18,17 @@ BETTER_AUTH_URL=http://localhost:4000
|
|||||||
|
|
||||||
# Gateway
|
# Gateway
|
||||||
GATEWAY_PORT=4000
|
GATEWAY_PORT=4000
|
||||||
|
|
||||||
|
# Discord Plugin (optional — set DISCORD_BOT_TOKEN to enable)
|
||||||
|
# DISCORD_BOT_TOKEN=
|
||||||
|
# DISCORD_GUILD_ID=
|
||||||
|
# DISCORD_GATEWAY_URL=http://localhost:4000
|
||||||
|
|
||||||
|
# Telegram Plugin (optional — set TELEGRAM_BOT_TOKEN to enable)
|
||||||
|
# TELEGRAM_BOT_TOKEN=
|
||||||
|
# TELEGRAM_GATEWAY_URL=http://localhost:4000
|
||||||
|
|
||||||
|
# Authentik SSO (optional — set AUTHENTIK_CLIENT_ID to enable)
|
||||||
|
# AUTHENTIK_ISSUER=https://auth.example.com
|
||||||
|
# AUTHENTIK_CLIENT_ID=
|
||||||
|
# AUTHENTIK_CLIENT_SECRET=
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
"@mosaic/coord": "workspace:^",
|
"@mosaic/coord": "workspace:^",
|
||||||
"@mosaic/db": "workspace:^",
|
"@mosaic/db": "workspace:^",
|
||||||
"@mosaic/discord-plugin": "workspace:^",
|
"@mosaic/discord-plugin": "workspace:^",
|
||||||
|
"@mosaic/telegram-plugin": "workspace:^",
|
||||||
"@mosaic/log": "workspace:^",
|
"@mosaic/log": "workspace:^",
|
||||||
"@mosaic/memory": "workspace:^",
|
"@mosaic/memory": "workspace:^",
|
||||||
"@mosaic/types": "workspace:^",
|
"@mosaic/types": "workspace:^",
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
type OnModuleInit,
|
type OnModuleInit,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { DiscordPlugin } from '@mosaic/discord-plugin';
|
import { DiscordPlugin } from '@mosaic/discord-plugin';
|
||||||
|
import { TelegramPlugin } from '@mosaic/telegram-plugin';
|
||||||
import { PluginService } from './plugin.service.js';
|
import { PluginService } from './plugin.service.js';
|
||||||
import type { IChannelPlugin } from './plugin.interface.js';
|
import type { IChannelPlugin } from './plugin.interface.js';
|
||||||
|
|
||||||
@@ -26,9 +27,23 @@ class DiscordChannelPluginAdapter implements IChannelPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TelegramChannelPluginAdapter implements IChannelPlugin {
|
||||||
|
readonly name = 'telegram';
|
||||||
|
|
||||||
|
constructor(private readonly plugin: TelegramPlugin) {}
|
||||||
|
|
||||||
|
async start(): Promise<void> {
|
||||||
|
await this.plugin.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
async stop(): Promise<void> {
|
||||||
|
await this.plugin.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const DEFAULT_GATEWAY_URL = 'http://localhost:4000';
|
const DEFAULT_GATEWAY_URL = 'http://localhost:4000';
|
||||||
|
|
||||||
function createPluginRegistry(logger: Logger): IChannelPlugin[] {
|
function createPluginRegistry(): IChannelPlugin[] {
|
||||||
const plugins: IChannelPlugin[] = [];
|
const plugins: IChannelPlugin[] = [];
|
||||||
const discordToken = process.env['DISCORD_BOT_TOKEN'];
|
const discordToken = process.env['DISCORD_BOT_TOKEN'];
|
||||||
const discordGuildId = process.env['DISCORD_GUILD_ID'];
|
const discordGuildId = process.env['DISCORD_GUILD_ID'];
|
||||||
@@ -50,8 +65,13 @@ function createPluginRegistry(logger: Logger): IChannelPlugin[] {
|
|||||||
const telegramGatewayUrl = process.env['TELEGRAM_GATEWAY_URL'] ?? DEFAULT_GATEWAY_URL;
|
const telegramGatewayUrl = process.env['TELEGRAM_GATEWAY_URL'] ?? DEFAULT_GATEWAY_URL;
|
||||||
|
|
||||||
if (telegramToken) {
|
if (telegramToken) {
|
||||||
logger.warn(
|
plugins.push(
|
||||||
`Telegram plugin requested for ${telegramGatewayUrl}, but @mosaic/telegram-plugin is not implemented yet.`,
|
new TelegramChannelPluginAdapter(
|
||||||
|
new TelegramPlugin({
|
||||||
|
token: telegramToken,
|
||||||
|
gatewayUrl: telegramGatewayUrl,
|
||||||
|
}),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +83,7 @@ function createPluginRegistry(logger: Logger): IChannelPlugin[] {
|
|||||||
providers: [
|
providers: [
|
||||||
{
|
{
|
||||||
provide: PLUGIN_REGISTRY,
|
provide: PLUGIN_REGISTRY,
|
||||||
useFactory: (): IChannelPlugin[] => createPluginRegistry(new Logger('PluginModule')),
|
useFactory: (): IChannelPlugin[] => createPluginRegistry(),
|
||||||
},
|
},
|
||||||
PluginService,
|
PluginService,
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user