summaryrefslogtreecommitdiff
path: root/protocols/WhatsAppWeb/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-04-19 14:36:04 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-04-19 14:36:04 +0300
commit7a6bb0b844b0a5c15191977acc79092771bb52b1 (patch)
treebb1334c59899baea00b706724552cd63d080263c /protocols/WhatsAppWeb/src
parent99f8fd05b99fbe8df51ba05ee859a419962a535e (diff)
Chat_Mute - a function to set group chat mute mode programmatically
Diffstat (limited to 'protocols/WhatsAppWeb/src')
-rw-r--r--protocols/WhatsAppWeb/src/proto.h16
-rw-r--r--protocols/WhatsAppWeb/src/server.cpp20
-rw-r--r--protocols/WhatsAppWeb/src/stdafx.h2
3 files changed, 23 insertions, 15 deletions
diff --git a/protocols/WhatsAppWeb/src/proto.h b/protocols/WhatsAppWeb/src/proto.h
index 1f83c8683d..d165b43361 100644
--- a/protocols/WhatsAppWeb/src/proto.h
+++ b/protocols/WhatsAppWeb/src/proto.h
@@ -8,20 +8,6 @@ Copyright © 2019-21 George Hazan
#if !defined(PROTO_H)
#define PROTO_H
-struct WAChatInfo
-{
- WAChatInfo(wchar_t *_jid, wchar_t *_nick) :
- tszJid(_jid), tszNick(_nick)
- {
- bActive = false;
- }
-
- ptrW tszJid, tszNick, tszOwner;
- bool bActive;
-
- MCONTACT hContact;
-};
-
class WhatsAppProto;
typedef void (WhatsAppProto:: *WA_PKT_HANDLER)(const JSONNode &node);
@@ -46,6 +32,7 @@ struct WAUser
}
MCONTACT hContact;
+ DWORD dwModifyTag;
char *szId;
SESSION_INFO *si = 0;
};
@@ -109,6 +96,7 @@ class WhatsAppProto : public PROTO<WhatsAppProto>
// binary packets
void ProcessBinaryPacket(const MBinBuffer &buf);
+ void ProcessChats(const JSONNode &node);
void ProcessContacts(const JSONNode &node);
// text packets
diff --git a/protocols/WhatsAppWeb/src/server.cpp b/protocols/WhatsAppWeb/src/server.cpp
index 08285815c8..2668a9955a 100644
--- a/protocols/WhatsAppWeb/src/server.cpp
+++ b/protocols/WhatsAppWeb/src/server.cpp
@@ -435,6 +435,26 @@ void WhatsAppProto::ProcessBinaryPacket(const MBinBuffer &buf)
CMStringA szType = root["type"].as_mstring();
if (szType == "contacts")
ProcessContacts(root["$list$"]);
+ else if (szType == "chat")
+ ProcessChats(root["$list$"]);
+}
+
+void WhatsAppProto::ProcessChats(const JSONNode &list)
+{
+ for (auto &it : list) {
+ CMStringW jid(it["jid"].as_mstring());
+ auto *pUser = AddUser(T2Utf(jid), false);
+
+ DWORD dwLastId = it["t"].as_int();
+ setDword(pUser->hContact, "LastWriteTime", dwLastId);
+
+ pUser->dwModifyTag = it["modify_tag"].as_int();
+
+ if (pUser->si) {
+ DWORD dwMute = _wtoi(it["mute"].as_mstring());
+ Chat_Mute(pUser->si, dwMute ? CHATMODE_MUTE : CHATMODE_NORMAL);
+ }
+ }
}
void WhatsAppProto::ProcessContacts(const JSONNode &list)
diff --git a/protocols/WhatsAppWeb/src/stdafx.h b/protocols/WhatsAppWeb/src/stdafx.h
index a89e28976e..4aa4febb1a 100644
--- a/protocols/WhatsAppWeb/src/stdafx.h
+++ b/protocols/WhatsAppWeb/src/stdafx.h
@@ -14,7 +14,7 @@ Copyright © 2019-21 George Hazan
#include <newpluginapi.h>
#include <m_avatars.h>
-#include <m_chat.h>
+#include <m_chat_int.h>
#include <m_clist.h>
#include <m_contacts.h>
#include <m_database.h>