mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-13 01:23:16 +08:00
fix: preserve Telegram compatibility and stabilize Office
This commit is contained in:
parent
7f114e1c36
commit
24e690498b
23 changed files with 1679 additions and 314 deletions
|
|
@ -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 }));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue