From 67382bca8cdfb020a56dbab3087233c3f1034426 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 15 Sep 2023 14:22:08 +0300 Subject: =?UTF-8?q?fixes=20#3674=20(=D0=A0=D0=B5=D0=B0=D0=BA=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BF=D1=80=D0=BE=D1=82=D0=BE=D0=BA=D0=BE=D0=BB=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=BD=D0=B0=20=D0=BE=D1=82=D1=81=D1=8B=D0=BB=D0=BA?= =?UTF-8?q?=D1=83=20=D0=B2=20=D0=BE=D1=84=D1=84=D0=BB=D0=B0=D0=B9=D0=BD)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Telegram/src/proto.h | 9 ++++----- protocols/Telegram/src/server.cpp | 20 +++++++++----------- 2 files changed, 13 insertions(+), 16 deletions(-) (limited to 'protocols/Telegram/src') diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index ad11cce7bf..c3d0252a06 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -194,8 +194,7 @@ class CTelegramProto : public PROTO TD::array m_deleteIds; bool m_bAuthorized, m_bTerminated, m_bUnregister = false, m_bSmileyAdd = false; - int32_t m_iClientId, m_iMsgId; - int64_t m_iQueryId; + int32_t m_iClientId, m_iQueryId; OBJLIST m_arOwnMsg; OBJLIST m_arRequests; @@ -217,7 +216,7 @@ class CTelegramProto : public PROTO void OnGetFileInfo(td::ClientManager::Response &response, void *pUserInfo); void OnGetHistory(td::ClientManager::Response &response, void *pUserInfo); void OnSendFile(td::ClientManager::Response &response, void *pUserInfo); - void OnSendMessage(td::ClientManager::Response &response, void *pUserInfo); + void OnSendMessage(td::ClientManager::Response &response); void OnUpdateAuth(td::ClientManager::Response &response); void LogOut(void); @@ -227,8 +226,8 @@ class CTelegramProto : public PROTO void SendKeepAlive(void); void SendDeleteMsg(void); void SendMarkRead(void); - void SendQuery(TD::Function *pFunc, TG_QUERY_HANDLER pHandler = nullptr); - void SendQuery(TD::Function *pFunc, TG_QUERY_HANDLER_FULL pHandler, void *pUserInfo); + int SendQuery(TD::Function *pFunc, TG_QUERY_HANDLER pHandler = nullptr); + int SendQuery(TD::Function *pFunc, TG_QUERY_HANDLER_FULL pHandler, void *pUserInfo); int SendTextMessage(int64_t chatId, const char *pszMessage); void ProcessAuth(TD::updateAuthorizationState *pObj); diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 878a24d61e..3eb42bd103 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -240,7 +240,7 @@ void CTelegramProto::ProcessResponse(td::ClientManager::Response response) ///////////////////////////////////////////////////////////////////////////////////////// -void CTelegramProto::OnSendMessage(td::ClientManager::Response &response, void *pUserInfo) +void CTelegramProto::OnSendMessage(td::ClientManager::Response &response) { if (!response.object) return; @@ -253,13 +253,11 @@ void CTelegramProto::OnSendMessage(td::ClientManager::Response &response, void * auto *pMessage = ((TD::message *)response.object.get()); auto *pUser = FindChat(pMessage->chat_id_); if (pUser) - m_arOwnMsg.insert(new TG_OWN_MESSAGE(pUser->hContact, pUserInfo, pMessage->id_)); + m_arOwnMsg.insert(new TG_OWN_MESSAGE(pUser->hContact, (HANDLE)response.request_id, pMessage->id_)); } int CTelegramProto::SendTextMessage(int64_t chatId, const char *pszMessage) { - int ret = ++m_iMsgId; - auto pContent = TD::make_object(); pContent->text_ = TD::make_object(); pContent->text_->text_ = std::move(pszMessage); @@ -267,15 +265,13 @@ int CTelegramProto::SendTextMessage(int64_t chatId, const char *pszMessage) auto *pMessage = new TD::sendMessage(); pMessage->chat_id_ = chatId; pMessage->input_message_content_ = std::move(pContent); - SendQuery(pMessage, &CTelegramProto::OnSendMessage, (void *)ret); - - return ret; + return SendQuery(pMessage, &CTelegramProto::OnSendMessage); } -void CTelegramProto::SendQuery(TD::Function *pFunc, TG_QUERY_HANDLER pHandler) +int CTelegramProto::SendQuery(TD::Function *pFunc, TG_QUERY_HANDLER pHandler) { if (!m_pClientManager) - return; + return -1; int queryId = ++m_iQueryId; @@ -286,12 +282,13 @@ void CTelegramProto::SendQuery(TD::Function *pFunc, TG_QUERY_HANDLER pHandler) if (pHandler) m_arRequests.insert(new TG_REQUEST(queryId, pHandler)); + return queryId; } -void CTelegramProto::SendQuery(TD::Function *pFunc, TG_QUERY_HANDLER_FULL pHandler, void *pUserInfo) +int CTelegramProto::SendQuery(TD::Function *pFunc, TG_QUERY_HANDLER_FULL pHandler, void *pUserInfo) { if (!m_pClientManager) - return; + return -1; int queryId = ++m_iQueryId; @@ -302,6 +299,7 @@ void CTelegramProto::SendQuery(TD::Function *pFunc, TG_QUERY_HANDLER_FULL pHandl if (pHandler) m_arRequests.insert(new TG_REQUEST_FULL(queryId, pHandler, pUserInfo)); + return queryId; } /////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3