fix: use searchChatMessages instead of getChatHistory for channel scanning

getChatHistory fails silently in supergroups with hidden history for new
members, returning only system messages. searchChatMessages with document
and photo filters works regardless of history visibility settings.

Also adds getChats call after TDLib client creation to populate the chat
list, preventing 'Chat not found' errors.
This commit is contained in:
admin
2026-03-21 20:15:18 +01:00
parent fe7a548fef
commit ba3d3a6040
2 changed files with 83 additions and 87 deletions

View File

@@ -333,6 +333,18 @@ export async function runWorkerForAccount(
phone: account.phone,
});
// Load the chat list so TDLib knows about all chats
// Without this, getChat/getChatHistory fail with "Chat not found"
try {
await client.invoke({
_: "getChats",
chat_list: { _: "chatListMain" },
limit: 1000,
});
} catch {
// Ignore — chat list may already be loaded
}
const counters = {
messagesScanned: 0,
zipsFound: 0,