From f34b6e62e80f8dd1e8c20ba26665a17301e5fbb8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 11 Feb 2025 19:55:32 +0300 Subject: Telegram: offline thread messages always fall into the main thread --- protocols/Telegram/src/utils.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'protocols/Telegram/src/utils.cpp') diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index 4e8a22192e..b1f98bb3f0 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -234,12 +234,10 @@ int CTelegramProto::GetDefaultMute(const TG_USER *pUser) MCONTACT CTelegramProto::GetRealContact(const TG_USER *pUser, int64_t threadId) { - if (threadId) { - wchar_t buf[100]; - mir_snwprintf(buf, L"%lld_%lld", pUser->chatId, threadId); - if (auto *si = Chat_Find(buf, m_szModuleName)) - return si->hContact; - } + if (threadId) + if (auto *pu = FindChat(pUser->chatId, threadId)) + return pu->hContact; + return (pUser->hContact != 0) ? pUser->hContact : m_iSavedMessages; } @@ -330,6 +328,15 @@ TG_USER* CTelegramProto::FindChat(int64_t id) { auto *tmp = (TG_USER *)_alloca(sizeof(TG_USER)); tmp->chatId = id; + tmp->forumId = -1; + return m_arChats.find(tmp); +} + +TG_USER* CTelegramProto::FindChat(int64_t id, int64_t forumId) +{ + auto *tmp = (TG_USER *)_alloca(sizeof(TG_USER)); + tmp->chatId = id; + tmp->forumId = forumId; return m_arChats.find(tmp); } -- cgit v1.2.3