summaryrefslogtreecommitdiff
path: root/protocols/Telegram/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-11-18 23:19:03 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-11-18 23:19:03 +0300
commiteaa7549c051641579edc045fbbab86c3129e85ee (patch)
tree2f0665840da2982aa121caed87dff87296d19574 /protocols/Telegram/src
parentf9d4be52548544305949dffedddc0d2044bdc45d (diff)
Telegram: fix for broken forum threads
Diffstat (limited to 'protocols/Telegram/src')
-rw-r--r--protocols/Telegram/src/groupchat.cpp10
-rw-r--r--protocols/Telegram/src/server.cpp9
2 files changed, 14 insertions, 5 deletions
diff --git a/protocols/Telegram/src/groupchat.cpp b/protocols/Telegram/src/groupchat.cpp
index a5c575c66d..e3a646dc03 100644
--- a/protocols/Telegram/src/groupchat.cpp
+++ b/protocols/Telegram/src/groupchat.cpp
@@ -197,13 +197,11 @@ int CTelegramProto::GcEventHook(WPARAM, LPARAM lParam)
if (mir_strcmpi(gch->si->pszModule, m_szModuleName))
return 0;
- auto userId = _wtoi64(gch->si->ptszID);
-
switch (gch->iType) {
case GC_USER_MESSAGE:
if (gch->ptszText && mir_wstrlen(gch->ptszText) > 0) {
rtrimw(gch->ptszText);
- if (auto *pUser = FindUser(userId)) {
+ if (auto *pUser = (TG_USER *)gch->si->pItemData) {
TD::int53 replyId = 0;
if (auto *pDlg = gch->si->pDlg) {
DB::EventInfo dbei(pDlg->m_hQuoteEvent, false);
@@ -416,11 +414,17 @@ void CTelegramProto::ProcessForum(TD::updateForumTopicInfo *pForum)
return;
}
+ auto *pInfo = pForum->info_.get();
if (pUser->m_si == nullptr) {
debugLogA("No parent chat for id %lld, skipping", pForum->chat_id_);
return;
}
+ if (pInfo->is_general_) {
+ SetId(pUser->m_si->hContact, pForum->info_->message_thread_id_, DBKEY_THREAD);
+ return;
+ }
+
wchar_t wszId[100];
mir_snwprintf(wszId, L"%lld_%lld", pForum->chat_id_, pForum->info_->message_thread_id_);
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index 0f97275314..e014f76a87 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -599,8 +599,13 @@ void CTelegramProto::ProcessChat(TD::updateNewChat *pObj)
m_arChats.insert(pUser);
if (!szTitle.empty()) {
- if (hContact != INVALID_CONTACT_ID)
- GcChangeTopic(pUser, szTitle);
+ if (hContact != INVALID_CONTACT_ID) {
+ if (pUser->isForum) {
+ pUser->wszNick = Utf2T(szTitle.c_str());
+ SendQuery(new TD::getForumTopics(pUser->chatId, "", 0, 0, 0, 100));
+ }
+ else GcChangeTopic(pUser, szTitle);
+ }
else if (pUser->wszNick.IsEmpty())
pUser->wszFirstName = Utf2T(szTitle.c_str());
}