summaryrefslogtreecommitdiff
path: root/protocols/Telegram
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-09-30 13:40:14 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-09-30 13:40:14 +0300
commit3ea151ed7440be73dccc664c0464e0dfc8e72ad0 (patch)
tree5dde4a49e4b7ca593d60da4e46422bed26a4b686 /protocols/Telegram
parentc90272a48520b1937624c0058f94b06e536f5ff6 (diff)
fixes #4696 (MessageState: add Telegram support)
Diffstat (limited to 'protocols/Telegram')
-rw-r--r--protocols/Telegram/src/main.cpp18
-rw-r--r--protocols/Telegram/src/server.cpp3
-rw-r--r--protocols/Telegram/src/stdafx.h4
3 files changed, 23 insertions, 2 deletions
diff --git a/protocols/Telegram/src/main.cpp b/protocols/Telegram/src/main.cpp
index 411a286ffc..a6b8ff67e8 100644
--- a/protocols/Telegram/src/main.cpp
+++ b/protocols/Telegram/src/main.cpp
@@ -46,10 +46,26 @@ static IconItem iconList[] =
{ LPGEN("Bot"), "bot", IDI_BOT },
};
+static int OnModuleLoaded(WPARAM, LPARAM)
+{
+ g_plugin.hasMessageState = ServiceExists(MS_MESSAGESTATE_UPDATE);
+ return 0;
+}
+
+static int OnModulesLoaded(WPARAM, LPARAM)
+{
+ HookEvent(ME_SYSTEM_MODULELOAD, OnModuleLoaded);
+ HookEvent(ME_SYSTEM_MODULEUNLOAD, OnModuleLoaded);
+ OnModuleLoaded(0, 0);
+ return 0;
+}
+
int CMPlugin::Load()
{
registerIcon("Protocols/Telegram", iconList, "tg");
-
+
+ HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
+
m_hIcon = ExtraIcon_RegisterIcolib("tg_premium", LPGEN("Telegram Premium user"), getIconHandle(IDI_PREMIUM));
return 0;
}
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index c2c8d3c1f2..b770fe42ef 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -880,6 +880,9 @@ void CTelegramProto::ProcessMarkRead(TD::updateChatReadInbox *pObj)
db_event_markRead(pUser->hContact, hEvent, true);
}
+ if (g_plugin.hasMessageState && pObj->unread_count_ == 0)
+ CallService(MS_MESSAGESTATE_UPDATE, GetRealContact(pUser), MRD_TYPE_READ);
+
if (Contact::IsGroupChat(pUser->hContact) && pObj->unread_count_ == 0)
delSetting(pUser->hContact, "ApparentMode");
}
diff --git a/protocols/Telegram/src/stdafx.h b/protocols/Telegram/src/stdafx.h
index 45fbab04cf..11bfb43809 100644
--- a/protocols/Telegram/src/stdafx.h
+++ b/protocols/Telegram/src/stdafx.h
@@ -25,6 +25,7 @@
#include <m_json.h>
#include <m_langpack.h>
#include <m_message.h>
+#include <m_messagestate.h>
#include <m_netlib.h>
#include <m_NewStory.h>
#include <m_options.h>
@@ -51,7 +52,8 @@ struct CMPlugin : public ACCPROTOPLUGIN<CTelegramProto>
{
CMPlugin();
- HANDLE m_hIcon;
+ bool hasMessageState = false;
+ HANDLE m_hIcon = 0;
int Load() override;
};