diff options
author | George Hazan <george.hazan@gmail.com> | 2023-12-09 20:01:34 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-12-09 20:01:34 +0300 |
commit | b96cd0c6250570ec58eda0e7c534bd39c62418a1 (patch) | |
tree | a1bfe7b891c394d2e09077aa3aaef1ce3637b344 /protocols | |
parent | dbc48cc0ec4df774c257d5175d62bce16e2437e3 (diff) |
fixes #4029 (Telegram: при покидании группы путём удаления контакта из базы, группа остаётся висеть в списке контактов серой)
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Telegram/src/groupchat.cpp | 23 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.cpp | 18 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.h | 3 |
3 files changed, 29 insertions, 15 deletions
diff --git a/protocols/Telegram/src/groupchat.cpp b/protocols/Telegram/src/groupchat.cpp index 99198d452e..e63f633b9c 100644 --- a/protocols/Telegram/src/groupchat.cpp +++ b/protocols/Telegram/src/groupchat.cpp @@ -244,20 +244,27 @@ void CTelegramProto::Chat_LogMenu(GCHOOK *gch) } } -INT_PTR CTelegramProto::SvcLeaveChat(WPARAM hContact, LPARAM) +///////////////////////////////////////////////////////////////////////////////////////// + +void CTelegramProto::OnLeaveChat(td::ClientManager::Response &, void *pUserInfo) { - int64_t id = GetId(hContact); - if (auto *pUser = FindUser(id)) { - pUser->m_si = nullptr; - SendQuery(new TD::leaveChat(pUser->chatId)); - } + auto *pUser = (TG_USER *)pUserInfo; wchar_t wszId[100]; - _i64tow(id, wszId, 10); + _i64tow(pUser->id, wszId, 10); if (auto *si = Chat_Find(wszId, m_szModuleName)) Chat_Terminate(si); - db_delete_contact(hContact); + db_delete_contact(pUser->hContact); +} + +INT_PTR CTelegramProto::SvcLeaveChat(WPARAM hContact, LPARAM) +{ + int64_t id = GetId(hContact); + if (auto *pUser = FindUser(id)) { + pUser->m_si = nullptr; + SendQuery(new TD::leaveChat(pUser->chatId), &CTelegramProto::OnLeaveChat, pUser); + } return 0; } diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp index e112712128..8d15a38f33 100644 --- a/protocols/Telegram/src/proto.cpp +++ b/protocols/Telegram/src/proto.cpp @@ -116,22 +116,28 @@ void CTelegramProto::OnContactAdded(MCONTACT hContact) } } -void CTelegramProto::OnContactDeleted(MCONTACT hContact) +bool CTelegramProto::OnContactDeleted(MCONTACT hContact) { TD::int53 id = GetId(hContact); if (id == 0) - return; - - TD::array<TD::int53> ids; - ids.push_back(id); - SendQuery(new TD::removeContacts(std::move(ids))); + return false; if (auto *pUser = FindUser(id)) { + if (pUser->m_si) { + SvcLeaveChat(hContact, 0); + return false; + } + pUser->hContact = INVALID_CONTACT_ID; pUser->wszNick = getMStringW(hContact, "Nick"); pUser->wszFirstName = getMStringW(hContact, "FirstName"); pUser->wszLastName = getMStringW(hContact, "LastName"); } + + TD::array<TD::int53> ids; + ids.push_back(id); + SendQuery(new TD::removeContacts(std::move(ids))); + return true; } int CTelegramProto::OnEmptyHistory(WPARAM hContact, LPARAM) diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index 4edce9f591..a4f8520abf 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -227,6 +227,7 @@ class CTelegramProto : public PROTO<CTelegramProto> void OnGetHistory(td::ClientManager::Response &response, void *pUserInfo); void OnGetSessions(td::ClientManager::Response &response, void *pUserInfo); void OnKillSession(td::ClientManager::Response &response, void *pUserInfo); + void OnLeaveChat(td::ClientManager::Response &response, void *pUserInfo); void OnSendFile(td::ClientManager::Response &response, void *pUserInfo); void OnSendMessage(td::ClientManager::Response &response); void OnUpdateAuth(td::ClientManager::Response &response); @@ -366,7 +367,7 @@ public: void OnBuildProtoMenu() override; void OnContactAdded(MCONTACT hContact) override; - void OnContactDeleted(MCONTACT hContact) override; + bool OnContactDeleted(MCONTACT hContact) override; MWindow OnCreateAccMgrUI(MWindow hwndParent) override; void OnErase() override; void OnEventDeleted(MCONTACT, MEVENT) override; |