summaryrefslogtreecommitdiff
path: root/protocols/Telegram/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-09-15 14:22:08 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-09-15 14:22:13 +0300
commit67382bca8cdfb020a56dbab3087233c3f1034426 (patch)
treed4cffadcf330cce5527c3b021fcf799f02c17c76 /protocols/Telegram/src
parentc400f5c17af4996eb2ecf0597e17eb25c17857d8 (diff)
fixes #3674 (Реакция протоколов на отсылку в оффлайн)
Diffstat (limited to 'protocols/Telegram/src')
-rw-r--r--protocols/Telegram/src/proto.h9
-rw-r--r--protocols/Telegram/src/server.cpp20
2 files changed, 13 insertions, 16 deletions
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<CTelegramProto>
TD::array<TD::int53> 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<TG_OWN_MESSAGE> m_arOwnMsg;
OBJLIST<TG_REQUEST_BASE> m_arRequests;
@@ -217,7 +216,7 @@ class CTelegramProto : public PROTO<CTelegramProto>
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<CTelegramProto>
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<TD::inputMessageText>();
pContent->text_ = TD::make_object<TD::formattedText>();
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;
}
///////////////////////////////////////////////////////////////////////////////