diff options
author | George Hazan <ghazan@miranda.im> | 2023-03-29 13:05:35 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-03-29 13:05:35 +0300 |
commit | 0770a12fb1d36674053771f2c559c508725090af (patch) | |
tree | c9144cce3d78dba371ed97fe99da279f373e1ecd /protocols/Telegram/src | |
parent | a95b57678699388a4e40716eacd8af5931574d72 (diff) |
fixes #3402 (Telegram: mark read sending doesn't work sometimes)
Diffstat (limited to 'protocols/Telegram/src')
-rw-r--r-- | protocols/Telegram/src/avatars.cpp | 2 | ||||
-rw-r--r-- | protocols/Telegram/src/groupchat.cpp | 4 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.cpp | 25 | ||||
-rw-r--r-- | protocols/Telegram/src/proto.h | 5 | ||||
-rw-r--r-- | protocols/Telegram/src/server.cpp | 15 | ||||
-rw-r--r-- | protocols/Telegram/src/utils.cpp | 5 |
6 files changed, 31 insertions, 25 deletions
diff --git a/protocols/Telegram/src/avatars.cpp b/protocols/Telegram/src/avatars.cpp index 66d0710cbc..0253152df0 100644 --- a/protocols/Telegram/src/avatars.cpp +++ b/protocols/Telegram/src/avatars.cpp @@ -22,7 +22,7 @@ CMStringW CTelegramProto::GetAvatarFilename(MCONTACT hContact) CMStringW wszResult(GetAvatarPath());
const wchar_t *szFileType = ProtoGetAvatarExtension(getByte(hContact, "AvatarType", PA_FORMAT_JPEG));
- wszResult.AppendFormat(L"\\%s%s", getMStringW(hContact, DBKEY_ID).c_str(), szFileType);
+ wszResult.AppendFormat(L"\\%lld%s", GetId(hContact), szFileType);
return wszResult;
}
diff --git a/protocols/Telegram/src/groupchat.cpp b/protocols/Telegram/src/groupchat.cpp index 7c2729d776..48decfea3b 100644 --- a/protocols/Telegram/src/groupchat.cpp +++ b/protocols/Telegram/src/groupchat.cpp @@ -156,7 +156,7 @@ void CTelegramProto::StartGroupChat(td::ClientManager::Response &response, void int CTelegramProto::GcMuteHook(WPARAM hContact, LPARAM mode) { if (Proto_IsProtoOnContact(hContact, m_szModuleName)) { - if (auto *pUser = FindUser(_atoi64(getMStringA(hContact, DBKEY_ID)))) { + if (auto *pUser = FindUser(GetId(hContact))) { auto settings = TD::make_object<TD::chatNotificationSettings>(); memcpy(settings.get(), &pUser->notificationSettings, sizeof(pUser->notificationSettings)); @@ -223,7 +223,7 @@ void CTelegramProto::Chat_LogMenu(GCHOOK *gch) { switch (gch->dwData) { case IDM_LEAVE: - int64_t id(_atoi64(getMStringA(gch->si->hContact, DBKEY_ID))); + int64_t id = GetId(gch->si->hContact); if (auto *pUser = FindUser(id)) { pUser->m_si = nullptr; SendQuery(new TD::leaveChat(pUser->chatId)); diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp index 26cc4e31d9..df74510a59 100644 --- a/protocols/Telegram/src/proto.cpp +++ b/protocols/Telegram/src/proto.cpp @@ -93,7 +93,7 @@ CTelegramProto::~CTelegramProto() void CTelegramProto::OnContactDeleted(MCONTACT hContact) { - TD::int53 id = _atoi64(getMStringA(hContact, DBKEY_ID)); + TD::int53 id = GetId(hContact); if (id == 0) return; @@ -111,8 +111,7 @@ void CTelegramProto::OnContactDeleted(MCONTACT hContact) int CTelegramProto::OnEmptyHistory(WPARAM hContact, LPARAM) { if (Proto_IsProtoOnContact(hContact, m_szModuleName)) { - TD::int53 id = _atoi64(getMStringA(hContact, DBKEY_ID)); - if (auto *pUser = FindUser(id)) + if (auto *pUser = FindUser(GetId(hContact))) SendQuery(new TD::deleteChatHistory(pUser->chatId, true, true)); } @@ -189,22 +188,22 @@ void CTelegramProto::OnEventDeleted(MCONTACT hContact, MEVENT hDbEvent) if (!hContact) return; - ptrA userId(getStringA(hContact, DBKEY_ID)); - if (!userId) + auto *pUser = FindUser(GetId(hContact)); + if (!pUser) return; DBEVENTINFO dbei = {}; db_event_get(hDbEvent, &dbei); if (dbei.szId) { mir_cslock lck(m_csDeleteMsg); - if (m_deleteMsgContact) { - if (m_deleteMsgContact != hContact) + if (m_deleteChatId) { + if (m_deleteChatId != pUser->chatId) SendDeleteMsg(); m_impl.m_deleteMsg.Stop(); } - m_deleteMsgContact = hContact; + m_deleteChatId = pUser->chatId; m_deleteIds.push_back(_atoi64(dbei.szId)); m_impl.m_deleteMsg.Start(500); } @@ -215,22 +214,22 @@ void CTelegramProto::OnMarkRead(MCONTACT hContact, MEVENT hDbEvent) if (!hContact) return; - ptrA userId(getStringA(hContact, DBKEY_ID)); - if (!userId) + auto *pUser = FindUser(GetId(hContact)); + if (!pUser) return; DBEVENTINFO dbei = {}; db_event_get(hDbEvent, &dbei); if (dbei.szId) { mir_cslock lck(m_csMarkRead); - if (m_markContact) { - if (m_markContact != hContact) + if (m_markChatId) { + if (m_markChatId != hContact) SendMarkRead(); m_impl.m_markRead.Stop(); } - m_markContact = hContact; + m_markChatId = pUser->chatId; m_markIds.push_back(_atoi64(dbei.szId)); m_impl.m_markRead.Start(500); } diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index f4e1e69f8b..99ab0898ec 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -163,11 +163,11 @@ class CTelegramProto : public PROTO<CTelegramProto> TD::object_ptr<TD::AuthorizationState> pAuthState; mir_cs m_csMarkRead; - MCONTACT m_markContact = 0; + TD::int53 m_markChatId = 0; TD::array<TD::int53> m_markIds; mir_cs m_csDeleteMsg; - MCONTACT m_deleteMsgContact = 0; + TD::int53 m_deleteChatId = 0; TD::array<TD::int53> m_deleteIds; bool m_bAuthorized, m_bTerminated, m_bUnregister = false, m_bSmileyAdd = false; @@ -261,6 +261,7 @@ class CTelegramProto : public PROTO<CTelegramProto> TG_USER* AddUser(int64_t id, bool bIsChat); TG_USER* AddFakeUser(int64_t id, bool bIsChat); TG_USER* GetSender(const TD::MessageSender *pSender); + int64_t GetId(MCONTACT); void SetId(MCONTACT, int64_t id); // Popups diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp index 85afbae93d..1afc03c6a6 100644 --- a/protocols/Telegram/src/server.cpp +++ b/protocols/Telegram/src/server.cpp @@ -101,9 +101,8 @@ void CTelegramProto::SendDeleteMsg() m_impl.m_deleteMsg.Stop();
mir_cslock lck(m_csDeleteMsg);
- int64_t userId = _atoi64(getMStringA(m_deleteMsgContact, DBKEY_ID));
- SendQuery(new TD::deleteMessages(userId, std::move(m_deleteIds), true));
- m_markContact = 0;
+ SendQuery(new TD::deleteMessages(m_deleteChatId, std::move(m_deleteIds), true));
+ m_deleteChatId = 0;
}
void CTelegramProto::SendMarkRead()
@@ -111,9 +110,8 @@ void CTelegramProto::SendMarkRead() m_impl.m_markRead.Stop();
mir_cslock lck(m_csMarkRead);
- int64_t userId = _atoi64(getMStringA(m_markContact, DBKEY_ID));
- SendQuery(new TD::viewMessages(userId, 0, std::move(m_markIds), true));
- m_markContact = 0;
+ SendQuery(new TD::viewMessages(m_markChatId, 0, std::move(m_markIds), true));
+ m_markChatId = 0;
}
///////////////////////////////////////////////////////////////////////////////
@@ -273,8 +271,11 @@ void CTelegramProto::ProcessBasicGroup(TD::updateBasicGroup *pObj) {
auto *pBasicGroup = pObj->basic_group_.get();
if (pBasicGroup->upgraded_to_supergroup_id_)
- if (auto *pUser = FindUser(pBasicGroup->upgraded_to_supergroup_id_))
+ if (auto *pUser = FindUser(pBasicGroup->upgraded_to_supergroup_id_)) {
pUser->bLoadMembers = true;
+ if (pUser->m_si)
+ pUser->m_si->bHasNicklist = true;
+ }
auto iStatusId = pBasicGroup->status_->get_id();
if (iStatusId == TD::chatMemberStatusBanned::ID) {
diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index 5686e1aad1..0884188c16 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -88,6 +88,11 @@ void CTelegramProto::ReportSearchUser(TG_USER *pUser) /////////////////////////////////////////////////////////////////////////////////////////
+int64_t CTelegramProto::GetId(MCONTACT hContact)
+{
+ return _atoi64(getMStringA(hContact, DBKEY_ID));
+}
+
void CTelegramProto::SetId(MCONTACT hContact, int64_t id)
{
char szId[100];
|