diff options
author | George Hazan <ghazan@miranda.im> | 2023-01-07 21:13:52 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-01-07 21:13:52 +0300 |
commit | 6635344981d9bfb245ada6c685b3a179cfd6ef45 (patch) | |
tree | ae31aee90b002d803be85a03caeca687145d8248 /protocols/Telegram/src | |
parent | 21331cf681e7f1fb0729109de251d0cc61be6098 (diff) |
Telegram: simple version of marking messages read
Diffstat (limited to 'protocols/Telegram/src')
-rw-r--r-- | protocols/Telegram/src/mt_proto.cpp | 25 | ||||
-rw-r--r-- | protocols/Telegram/src/mt_proto.h | 1 |
2 files changed, 26 insertions, 0 deletions
diff --git a/protocols/Telegram/src/mt_proto.cpp b/protocols/Telegram/src/mt_proto.cpp index a99c91eb31..d00f84c434 100644 --- a/protocols/Telegram/src/mt_proto.cpp +++ b/protocols/Telegram/src/mt_proto.cpp @@ -32,6 +32,7 @@ CMTProto::CMTProto(const char* protoName, const wchar_t* userName) : CreateProtoService(PS_CREATEACCMGRUI, &CMTProto::SvcCreateAccMgrUI); HookProtoEvent(ME_OPT_INITIALISE, &CMTProto::OnOptionsInit); + HookProtoEvent(ME_DB_EVENT_MARKED_READ, &CMTProto::OnDbMarkedRead); // default contacts group if (m_wszDefaultGroup == NULL) @@ -87,6 +88,30 @@ void CMTProto::OnErase() DeleteDirectoryTreeW(GetProtoFolder(), false); } +int CMTProto::OnDbMarkedRead(WPARAM hContact, LPARAM hDbEvent) +{ + if (!hContact) + return 0; + + // filter out only events of my protocol + const char *szProto = Proto_GetBaseAccountName(hContact); + if (mir_strcmp(szProto, m_szModuleName)) + return 0; + + ptrA userId(getStringA(hContact, DBKEY_ID)); + if (userId) { + DBEVENTINFO dbei = {}; + db_event_get(hDbEvent, &dbei); + if (dbei.szId) { + TD::array<TD::int53> ids; + ids.push_back(_atoi64(dbei.szId)); + SendQuery(new TD::viewMessages(_atoi64(userId), 0, std::move(ids), true)); + } + } + + return 0; +} + INT_PTR CMTProto::GetCaps(int type, MCONTACT) { switch (type) { diff --git a/protocols/Telegram/src/mt_proto.h b/protocols/Telegram/src/mt_proto.h index 7aa85b722b..46439aee5f 100644 --- a/protocols/Telegram/src/mt_proto.h +++ b/protocols/Telegram/src/mt_proto.h @@ -173,6 +173,7 @@ public: // Events //////////////////////////////////////////////////////////////////////////// int __cdecl OnOptionsInit(WPARAM, LPARAM); + int __cdecl OnDbMarkedRead(WPARAM, LPARAM); // Options /////////////////////////////////////////////////////////////////////////// |