From f58bf1b1c32a62f3b6f3d5dd309a86140ac2964d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 19 Oct 2022 20:42:14 +0300 Subject: WhatsApp: basic message processing --- protocols/WhatsAppWeb/src/server.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'protocols/WhatsAppWeb/src/server.cpp') diff --git a/protocols/WhatsAppWeb/src/server.cpp b/protocols/WhatsAppWeb/src/server.cpp index 3a83bc8f28..91f36b7df7 100644 --- a/protocols/WhatsAppWeb/src/server.cpp +++ b/protocols/WhatsAppWeb/src/server.cpp @@ -283,6 +283,27 @@ void WhatsAppProto::SendKeepAlive() } } +void WhatsAppProto::SendReceipt(const char *pszTo, const char *pszParticipant, const char *pszId, const char *pszType) +{ + WANode receipt("receipt"); + receipt << CHAR_PARAM("id", pszId); + + if (!mir_strcmp(pszType, "read") || !mir_strcmp(pszType, "read-self")) + receipt << INT_PARAM("t", time(0)); + + if (!mir_strcmp(pszType, "sender") && WAJid(pszTo).isUser()) + receipt << CHAR_PARAM("to", pszParticipant) << CHAR_PARAM("recipient", pszTo); + else { + receipt << CHAR_PARAM("to", pszTo); + if (pszParticipant) + receipt << CHAR_PARAM("participant", pszParticipant); + } + + if (pszType) + receipt << CHAR_PARAM("type", pszType); + WSSendNode(receipt, &WhatsAppProto::OnIqDoNothing); +} + void WhatsAppProto::SetServerStatus(int iStatus) { if (mir_wstrlen(m_wszNick)) -- cgit v1.2.3