diff options
Diffstat (limited to 'protocols/Telegram/src')
-rw-r--r-- | protocols/Telegram/src/proto.cpp | 8 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.h | 4 |
2 files changed, 9 insertions, 3 deletions
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp index 1354be1c33..731d7babf1 100644 --- a/protocols/Telegram/src/proto.cpp +++ b/protocols/Telegram/src/proto.cpp @@ -301,7 +301,9 @@ MEVENT CTelegramProto::RecvFile(MCONTACT hContact, PROTORECVFILE *pre) void CTelegramProto::OnSearchResults(td::ClientManager::Response &response) { - m_searchIds.clear(); + int iCount = ::InterlockedDecrement(&m_iSearchCount); + if (iCount == 0) + m_searchIds.clear(); if (!response.object) return; @@ -321,7 +323,7 @@ void CTelegramProto::OnSearchResults(td::ClientManager::Response &response) } } - if (m_searchIds.empty()) + if (iCount == 0) ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, this); } @@ -331,8 +333,10 @@ HANDLE CTelegramProto::SearchByName(const wchar_t *nick, const wchar_t *firstNam if (szQuery.GetLength() == 2) return nullptr; + m_iSearchCount = 2; szQuery.Trim(); SendQuery(new TD::searchPublicChats(szQuery.c_str()), &CTelegramProto::OnSearchResults); + SendQuery(new TD::searchChatsOnServer(szQuery.c_str(), 100), &CTelegramProto::OnSearchResults); return this; } diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index b0d57893d2..331a7b9d82 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -213,7 +213,6 @@ class CTelegramProto : public PROTO<CTelegramProto> void OnEndSession(td::ClientManager::Response &response); void OnGetFileInfo(td::ClientManager::Response &response, void *pUserInfo); void OnGetHistory(td::ClientManager::Response &response, void *pUserInfo); - void OnSearchResults(td::ClientManager::Response &response); void OnSendFile(td::ClientManager::Response &response, void *pUserInfo); void OnSendMessage(td::ClientManager::Response &response, void *pUserInfo); void OnUpdateAuth(td::ClientManager::Response &response); @@ -274,8 +273,11 @@ class CTelegramProto : public PROTO<CTelegramProto> bool GetGcUserId(TG_USER *pUser, const TD::message *pMsg, char *dest); // Search + volatile unsigned m_iSearchCount; TD::array<TD::int53> m_searchIds; + void OnSearchResults(td::ClientManager::Response &response); + bool CheckSearchUser(TG_USER *pUser); void ReportSearchUser(TG_USER *pUser); |