From da270c8f594c9846aa4e5d2f4b20c061e12426ff Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 2 Jan 2023 14:18:38 +0300 Subject: =?UTF-8?q?fixes=20#3287=20(=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C?= =?UTF-8?q?=20=D0=B2=20=D0=BF=D1=80=D0=BE=D1=84=D0=B8=D0=BB=D1=8C=20=D0=BC?= =?UTF-8?q?=D0=B8=D1=80=D0=B0=D0=BD=D0=B4=D1=8B=20=D0=BF=D0=BE=D0=BF=D0=B0?= =?UTF-8?q?=D0=B4=D0=B0=D1=8E=D1=82=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BD=D1=82=D0=B0=D0=BA=D1=82=D1=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Telegram/src/server.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'protocols') diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index ad7968ba15..8dede07c4c 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -54,6 +54,8 @@ void CMTProto::OnLoggedIn() ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, m_iDesiredStatus); m_iStatus = m_iDesiredStatus; + + SendQuery(new TD::getChats(td::tl::unique_ptr(), 1000)); } /////////////////////////////////////////////////////////////////////////////// @@ -163,6 +165,10 @@ int CMTProto::SendTextMessage(uint64_t chatId, const char *pszMessage) void CMTProto::SendQuery(TD::Function *pFunc, TG_QUERY_HANDLER pHandler) { int queryId = ++m_iQueryId; + + auto szDescr = to_string(*pFunc); + debugLogA("Sending query %d:\n%s", queryId, szDescr.c_str()); + m_pClientMmanager->send(m_iClientId, queryId, TD::object_ptr(pFunc)); if (pHandler) @@ -172,6 +178,10 @@ void CMTProto::SendQuery(TD::Function *pFunc, TG_QUERY_HANDLER pHandler) void CMTProto::SendQuery(TD::Function *pFunc, TG_QUERY_HANDLER_FULL pHandler, void *pUserInfo) { int queryId = ++m_iQueryId; + + auto szDescr = to_string(*pFunc); + debugLogA("Sending full query %d:\n%s", queryId, szDescr.c_str()); + m_pClientMmanager->send(m_iClientId, queryId, TD::object_ptr(pFunc)); if (pHandler) @@ -188,9 +198,9 @@ void CMTProto::ProcessChat(TD::updateNewChat *pObj) return; } - auto *pUser = AddUser(pChat->id_, false); - if (!pChat->title_.empty()) - setUString(pUser->hContact, "Nick", pChat->title_.c_str()); + if (auto *pUser = FindUser(pChat->id_)) + if (!pChat->title_.empty()) + setUString(pUser->hContact, "Nick", pChat->title_.c_str()); } void CMTProto::ProcessChatPosition(TD::updateChatPosition *pObj) @@ -245,7 +255,6 @@ void CMTProto::ProcessGroups(TD::updateChatFilters *pObj) setWString(szSetting, wszNewValue); } - SendQuery(new TD::getChats(TD::make_object(grp->id_), 1000)); } } @@ -307,6 +316,11 @@ void CMTProto::ProcessUser(TD::updateUser *pObj) m_arUsers.insert(new TG_USER(pUser->id_, 0)); } + if (!pUser->is_contact_) { + debugLogA("User doesn't belong to your contacts, skipping"); + return; + } + auto *pu = AddUser(pUser->id_, false); UpdateString(pu->hContact, "FirstName", pUser->first_name_); UpdateString(pu->hContact, "LastName", pUser->last_name_); -- cgit v1.2.3