diff options
author | George Hazan <george.hazan@gmail.com> | 2023-11-29 19:26:37 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-11-29 19:26:37 +0300 |
commit | 79e717d8e8afe090495da64477b670f7b6434544 (patch) | |
tree | 32a28bd057dbd44637509f6d9312d09297a15330 | |
parent | 2d4b8d7d26d1e45b0a8d54bdf81763b68a695e01 (diff) |
fixes #3989 (Telegram: когда чат превращается в супергруппу, он задваивается в Миранде)
-rw-r--r-- | protocols/Telegram/src/groupchat.cpp | 3 | ||||
-rw-r--r-- | protocols/Telegram/src/server.cpp | 20 | ||||
-rw-r--r-- | protocols/Telegram/src/utils.cpp | 12 |
3 files changed, 28 insertions, 7 deletions
diff --git a/protocols/Telegram/src/groupchat.cpp b/protocols/Telegram/src/groupchat.cpp index 4962a1ac85..bf3f8312a5 100644 --- a/protocols/Telegram/src/groupchat.cpp +++ b/protocols/Telegram/src/groupchat.cpp @@ -201,7 +201,8 @@ int CTelegramProto::GcEventHook(WPARAM, LPARAM lParam) if (gch->ptszText && mir_wstrlen(gch->ptszText) > 0) { rtrimw(gch->ptszText); Chat_UnescapeTags(gch->ptszText); - SendTextMessage(-userId, T2Utf(gch->ptszText)); + if (auto *pUser = FindUser(userId)) + SendTextMessage(pUser->chatId, T2Utf(gch->ptszText)); } break; diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index d75b12792e..3a81fb4aa3 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -413,15 +413,23 @@ INT_PTR CTelegramProto::SvcLoadServerHistory(WPARAM hContact, LPARAM) void CTelegramProto::ProcessBasicGroup(TD::updateBasicGroup *pObj)
{
auto *pBasicGroup = pObj->basic_group_.get();
- if (pBasicGroup->upgraded_to_supergroup_id_)
- if (auto *pUser = FindUser(pBasicGroup->upgraded_to_supergroup_id_)) {
- pUser->bLoadMembers = true;
- if (pUser->m_si)
- pUser->m_si->bHasNicklist = true;
- }
auto iStatusId = pBasicGroup->status_->get_id();
if (iStatusId == TD::chatMemberStatusBanned::ID) {
+ if (pBasicGroup->upgraded_to_supergroup_id_) {
+ auto *pUser = FindUser(pBasicGroup->upgraded_to_supergroup_id_);
+ if (pUser) {
+ pUser->bLoadMembers = true;
+ if (pUser->m_si)
+ pUser->m_si->bHasNicklist = true;
+
+ if (auto *pOldUser = FindUser(pBasicGroup->id_)) {
+ pUser->hContact = pOldUser->hContact;
+ SetId(pUser->hContact, pBasicGroup->upgraded_to_supergroup_id_);
+ }
+ }
+ }
+
debugLogA("We are banned here, skipping");
return;
}
diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index 840ee15946..414a9bdc7a 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -451,6 +451,18 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg pszUserId = szUserId;
switch (pBody->get_id()) {
+ case TD::messageChatUpgradeTo::ID:
+ {
+ auto *pUgrade = (TD::messageChatUpgradeTo *)pBody;
+ MCONTACT hContact = pUser->hContact;
+ m_arChats.remove(pUser);
+ m_arUsers.remove(pUser);
+ SetId(hContact, pUgrade->supergroup_id_);
+ pUser = new TG_USER(pUgrade->supergroup_id_, hContact, true);
+ m_arUsers.insert(pUser);
+ }
+ break;
+
case TD::messagePhoto::ID:
{
auto *pDoc = (TD::messagePhoto *)pBody;
|