summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Telegram/src/main.cpp1
-rw-r--r--protocols/Telegram/src/proto.cpp19
-rw-r--r--protocols/Telegram/src/proto.h1
-rw-r--r--protocols/Telegram/src/server.cpp13
-rw-r--r--protocols/Telegram/src/stdafx.h2
5 files changed, 24 insertions, 12 deletions
diff --git a/protocols/Telegram/src/main.cpp b/protocols/Telegram/src/main.cpp
index a6b8ff67e8..3038e826b7 100644
--- a/protocols/Telegram/src/main.cpp
+++ b/protocols/Telegram/src/main.cpp
@@ -48,6 +48,7 @@ static IconItem iconList[] =
static int OnModuleLoaded(WPARAM, LPARAM)
{
+ g_plugin.hasNewStory = ServiceExists("NewStory/RemoteRead");
g_plugin.hasMessageState = ServiceExists(MS_MESSAGESTATE_UPDATE);
return 0;
}
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp
index 355d137256..17c8e04cb7 100644
--- a/protocols/Telegram/src/proto.cpp
+++ b/protocols/Telegram/src/proto.cpp
@@ -184,13 +184,18 @@ void CTelegramProto::OnShutdown()
int CTelegramProto::OnWindowEvent(WPARAM wParam, LPARAM lParam)
{
- if (wParam == MSG_WINDOW_EVT_OPENING) {
- auto *pDlg = (CMsgDialog *)lParam;
- if (Proto_IsProtoOnContact(pDlg->m_hContact, m_szModuleName))
- if (auto *pUser = FindUser(GetId(pDlg->m_hContact)))
- if (pUser->chatId == -1 && !pDlg->isChat())
- SendQuery(new TD::createPrivateChat(pUser->id, true));
- }
+ auto *pDlg = (CMsgDialog *)lParam;
+ if (!Proto_IsProtoOnContact(pDlg->m_hContact, m_szModuleName))
+ return 0;
+
+ auto *pUser = FindUser(GetId(pDlg->m_hContact));
+ if (pUser == nullptr)
+ return 0;
+
+ if (wParam == MSG_WINDOW_EVT_OPENING)
+ if (pUser->chatId == -1 && !pDlg->isChat())
+ SendQuery(new TD::createPrivateChat(pUser->id, true));
+
return 0;
}
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index 5801fb30dc..4d76651b48 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -5,6 +5,7 @@
#define DBKEY_OWNER "OwnerId"
#define DBKEY_THREAD "ThreadId"
#define DBKEY_AUTHORIZED "Authorized"
+#define DBKEY_REMOTE_READ "RemoteRead"
#define DBKEY_AVATAR_HASH "AvatarHash"
#define DBKEY_AVATAR_TYPE "AvatarType"
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index 2d3062d700..681a4344be 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -1087,10 +1087,15 @@ void CTelegramProto::ProcessRemoteMarkRead(TD::updateChatReadOutbox *pObj)
CMStringA szMaxId(msg2id(pUser->chatId, pObj->last_read_outbox_message_id_));
MarkRead(pUser->hContact, szMaxId, true);
- CallService(MS_MESSAGESTATE_UPDATE, GetRealContact(pUser), MRD_TYPE_READ);
-
- if (auto hEvent = db_event_getById(m_szModuleName, szMaxId))
- NS_NotifyRemoteRead(GetRealContact(pUser), hEvent);
+ auto hContact = GetRealContact(pUser);
+ if (g_plugin.hasMessageState)
+ CallService(MS_MESSAGESTATE_UPDATE, hContact, MRD_TYPE_READ);
+
+ if (auto hEvent = db_event_getById(m_szModuleName, szMaxId)) {
+ setDword(hContact, DBKEY_REMOTE_READ, hEvent);
+ if (g_plugin.hasNewStory)
+ NS_NotifyRemoteRead(hContact, hEvent);
+ }
}
void CTelegramProto::ProcessScopeNotification(TD::updateScopeNotificationSettings *pObj)
diff --git a/protocols/Telegram/src/stdafx.h b/protocols/Telegram/src/stdafx.h
index 11bfb43809..8b583a6cba 100644
--- a/protocols/Telegram/src/stdafx.h
+++ b/protocols/Telegram/src/stdafx.h
@@ -52,7 +52,7 @@ struct CMPlugin : public ACCPROTOPLUGIN<CTelegramProto>
{
CMPlugin();
- bool hasMessageState = false;
+ bool hasMessageState = false, hasNewStory = false;
HANDLE m_hIcon = 0;
int Load() override;