diff options
Diffstat (limited to 'protocols/Telegram/src/mt_proto.cpp')
-rw-r--r-- | protocols/Telegram/src/mt_proto.cpp | 25 |
1 files changed, 25 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) { |