fix: preserve Telegram compatibility and stabilize Office

This commit is contained in:
xmanrui 2026-08-21 01:37:21 +08:00
parent 7f114e1c36
commit 24e690498b
23 changed files with 1679 additions and 314 deletions

View file

@ -1,9 +1,15 @@
import { TokenBotController } from '../shared/token-bot-controller.mjs';
import { deriveTelegramBotIdentity, maskTelegramBotId } from './config-store.mjs';
import {
deriveTelegramBotIdentity,
maskTelegramBotId,
normalizeTelegramAccessPolicy,
} from './config-store.mjs';
import { inspectTelegramToken } from './telegram-api.mjs';
import { TELEGRAM_DESCRIPTOR } from './telegram-bridge.mjs';
export class TelegramController extends TokenBotController {
#configStore;
constructor(options) {
super({
...options,
@ -12,5 +18,23 @@ export class TelegramController extends TokenBotController {
deriveIdentity: deriveTelegramBotIdentity,
maskPlatformId: maskTelegramBotId,
});
this.#configStore = options.configStore;
}
status() {
const snapshot = super.status();
return {
...snapshot,
bots: snapshot.bots.map((bot) => {
const config = this.#configStore.get(bot.botId);
const accessPolicy = normalizeTelegramAccessPolicy(config ?? {});
return { ...bot, accessPolicy };
}),
};
}
async setAccessPolicy(botId, value) {
const accessPolicy = normalizeTelegramAccessPolicy(value);
return this.updateBotConfig(botId, (config) => ({ ...config, ...accessPolicy }));
}
}