From cb73d3cc19a6f27185c5228ce604312fc3203797 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 27 Nov 2024 21:42:32 +0300 Subject: Telegram: more correct way of thread history fetching --- protocols/Telegram/src/server.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index c62aedca58..952e076940 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -502,15 +502,20 @@ INT_PTR CTelegramProto::SvcLoadServerHistory(WPARAM hContact, LPARAM) lastMsgId = dbei2id(dbei); } + auto userId = GetId(hContact); + if (TD::int53 threadId = GetId(hContact, DBKEY_THREAD)) { - auto chatId = GetId(hContact); - auto *pUser = new TG_USER(-1, hContact, true); - pUser->chatId = chatId; - pUser->isForum = pUser->isGroupChat = true; - pUser->nHistoryChunks = 5; - SendQuery(new TD::getMessageThreadHistory(chatId, lastMsgId, lastMsgId, 0, 100), &CTelegramProto::OnGetHistory, pUser); + if (FindChat(userId)) { + auto *pUser = new TG_USER(-1, hContact, true); + pUser->chatId = userId; + pUser->isForum = pUser->isGroupChat = true; + pUser->nHistoryChunks = 5; + SendQuery(new TD::getMessageThreadHistory(pUser->chatId, lastMsgId, lastMsgId, 0, 100), &CTelegramProto::OnGetHistory, pUser); + return 0; + } } - else if (auto *pUser = FindUser(GetId(hContact))) { + + if (auto *pUser = FindUser(userId)) { pUser->nHistoryChunks = 5; SendQuery(new TD::getChatHistory(pUser->chatId, lastMsgId, 0, 100, false), &CTelegramProto::OnGetHistory, pUser); } -- cgit v1.2.3