fix: support large accounts and archived chats in channel discovery
Some checks failed
continuous-integration/drone/push Build is failing

- Increase getChats pagination from 50 pages (5K chats) to 500 pages
  (50K chats) to support accounts with many channels/groups
- Load from both chatListMain AND chatListArchive so older/archived
  chats are discovered and scannable
- Deduplicate chat IDs across both lists
- Worker startup also loads both lists before scanning

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-23 19:50:14 +01:00
parent 29e95f780c
commit aef76828ef
2 changed files with 95 additions and 79 deletions

View File

@@ -338,17 +338,23 @@ export async function runWorkerForAccount(
// Load the full chat list so TDLib knows about all chats.
// Without this, getChat/searchChatMessages fail with "Chat not found".
// TDLib returns chats in batches — keep calling until empty.
try {
for (let page = 0; page < 50; page++) {
const chatResult = await client.invoke({
_: "getChats",
chat_list: { _: "chatListMain" },
limit: 100,
}) as { chat_ids?: number[] };
if (!chatResult.chat_ids || chatResult.chat_ids.length === 0) break;
// Load from both main and archive lists to cover older/archived chats.
for (const chatList of [
{ _: "chatListMain" as const },
{ _: "chatListArchive" as const },
]) {
try {
for (let page = 0; page < 500; page++) {
const chatResult = await client.invoke({
_: "getChats",
chat_list: chatList,
limit: 100,
}) as { chat_ids?: number[] };
if (!chatResult.chat_ids || chatResult.chat_ids.length === 0) break;
}
} catch {
// Ignore — chat list may already be loaded
}
} catch {
// Ignore — chat list may already be loaded
}
const counters = {