惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
L
LangChain Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
罗磊的独立博客
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 叶小钗
小众软件
小众软件
博客园 - Franky
D
Docker
Google DeepMind News
Google DeepMind News
Microsoft Azure Blog
Microsoft Azure Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
U
Unit 42
宝玉的分享
宝玉的分享
C
Check Point Blog
B
Blog
V
V2EX
博客园 - 三生石上(FineUI控件)
MyScale Blog
MyScale Blog
The Cloudflare Blog
博客园 - 聂微东
博客园_首页
Engineering at Meta
Engineering at Meta

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
perf(telegram): cache forum metadata lookup · openclaw/op...
obviyus · 2026-04-23 · via Recent Commits to openclaw:main

File tree

  • extensions/telegram/src/bot

Original file line numberDiff line numberDiff line change

@@ -52,13 +52,26 @@ describe("resolveTelegramForumFlag", () => {

5252

const getChat = vi.fn(async () => ({ is_forum: true }));

5353

await expect(

5454

resolveTelegramForumFlag({

55-

chatId: -100123,

55+

chatId: -100789,

5656

chatType: "supergroup",

5757

isGroup: true,

5858

getChat,

5959

}),

6060

).resolves.toBe(true);

61-

expect(getChat).toHaveBeenCalledWith(-100123);

61+

expect(getChat).toHaveBeenCalledWith(-100789);

62+

});

63+
64+

it("reuses resolved forum metadata for later supergroup updates", async () => {

65+

const getChat = vi.fn(async () => ({ is_forum: true }));

66+

const params = {

67+

chatId: -100456,

68+

chatType: "supergroup" as const,

69+

isGroup: true,

70+

getChat,

71+

};

72+

await expect(resolveTelegramForumFlag(params)).resolves.toBe(true);

73+

await expect(resolveTelegramForumFlag(params)).resolves.toBe(true);

74+

expect(getChat).toHaveBeenCalledTimes(1);

6275

});

6376
6477

it("returns false when forum lookup is unavailable", async () => {

@@ -67,7 +80,7 @@ describe("resolveTelegramForumFlag", () => {

6780

});

6881

await expect(

6982

resolveTelegramForumFlag({

70-

chatId: -100123,

83+

chatId: -100999,

7184

chatType: "supergroup",

7285

isGroup: true,

7386

getChat,

Original file line numberDiff line numberDiff line change

@@ -40,6 +40,7 @@ export {

4040

};

4141
4242

const TELEGRAM_GENERAL_TOPIC_ID = 1;

43+

const telegramForumFlagByChatId = new Map<string, boolean>();

4344
4445

function hadUnsafeTelegramText(raw: unknown, sanitized: string): boolean {

4546

return typeof raw === "string" && raw.trim().length > 0 && sanitized.trim().length === 0;

@@ -71,8 +72,15 @@ export async function resolveTelegramForumFlag(params: {

7172

if (!params.isGroup || params.chatType !== "supergroup" || !params.getChat) {

7273

return false;

7374

}

75+

const cacheKey = String(params.chatId);

76+

const cached = telegramForumFlagByChatId.get(cacheKey);

77+

if (cached !== undefined) {

78+

return cached;

79+

}

7480

try {

75-

return extractTelegramForumFlag(await params.getChat(params.chatId)) === true;

81+

const resolved = extractTelegramForumFlag(await params.getChat(params.chatId)) === true;

82+

telegramForumFlagByChatId.set(cacheKey, resolved);

83+

return resolved;

7684

} catch {

7785

return false;

7886

}