diff options
author | George Hazan <george.hazan@gmail.com> | 2023-06-07 21:12:45 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-06-07 21:12:45 +0300 |
commit | 41485625eeed7d42935c7f06157ae45be3aa76e3 (patch) | |
tree | 79d3f1b49e68420266f61f7d83eb41a711c56483 /protocols/Telegram | |
parent | a2a06f0dabca964ba98049fc68fab57aebbe8c5f (diff) |
fixes #3390 (Telegram: не получается добавить бота, с которым уже было взаимодействие, но потом диалог был удален)
Diffstat (limited to 'protocols/Telegram')
-rw-r--r-- | protocols/Telegram/src/proto.cpp | 8 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.h | 4 | ||||
-rw-r--r-- | protocols/Telegram/tdlib/td/td/tl/TlObject.h | 4 |
3 files changed, 11 insertions, 5 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); diff --git a/protocols/Telegram/tdlib/td/td/tl/TlObject.h b/protocols/Telegram/tdlib/td/td/tl/TlObject.h index c1b363fc97..d6c9e1cd9d 100644 --- a/protocols/Telegram/tdlib/td/td/tl/TlObject.h +++ b/protocols/Telegram/tdlib/td/td/tl/TlObject.h @@ -39,14 +39,14 @@ class TlObject { * Appends the object to the storer serializing object, a buffer of fixed length. * \param[in] s Storer to which the object will be appended. */ - virtual void store(TlStorerUnsafe &s) const { + virtual void store(TlStorerUnsafe &) const { } /** * Appends the object to the storer, calculating the TL-length of the serialized object. * \param[in] s Storer to which the object will be appended. */ - virtual void store(TlStorerCalcLength &s) const { + virtual void store(TlStorerCalcLength &) const { } /** |