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,24 @@
import { TOKEN_BOT_ENDPOINTS, createTokenChannelApi } from '../shared/token-api.js';
export const TELEGRAM_RPC_CHANNEL = '/telegram';
export const TELEGRAM_ENDPOINTS = TOKEN_BOT_ENDPOINTS;
export const TELEGRAM_ENDPOINTS = Object.freeze({
...TOKEN_BOT_ENDPOINTS,
setAccessPolicy: 'bot.access-policy.set',
});
const api = createTokenChannelApi('Telegram', ' Bot API 长轮询');
const api = createTokenChannelApi('Telegram', ' Bot API 长轮询', {
normalizeBotExtension: (value) => {
const source = value?.accessPolicy;
const accessMode = source?.accessMode === 'private-allowlist'
? 'private-allowlist' : 'compatible';
const allowedUsers = Array.isArray(source?.allowedUsers)
? [...new Set(source.allowedUsers.filter((entry) => (
typeof entry === 'string' && /^[1-9]\d{0,15}$/.test(entry)
)))]
: [];
return { accessPolicy: { accessMode, allowedUsers } };
},
});
export const unwrapRpcResult = api.unwrapRpcResult;
export const normalizeSnapshot = api.normalizeSnapshot;