From 19188a13f7bfc07d453df5fe9d42a75a1b4dbe83 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 3 Nov 2022 21:22:06 +0300 Subject: WhatsApp: receiving group chats messages --- protocols/WhatsApp/src/appsync.cpp | 29 +++++++++++++++++++++-------- protocols/WhatsApp/src/message.cpp | 30 +++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/protocols/WhatsApp/src/appsync.cpp b/protocols/WhatsApp/src/appsync.cpp index 36531a5179..8ab4416fc3 100644 --- a/protocols/WhatsApp/src/appsync.cpp +++ b/protocols/WhatsApp/src/appsync.cpp @@ -272,14 +272,27 @@ void WhatsAppProto::ProcessHistorySync(const Wa__HistorySync *pSync) CMStringA szMessageText(GetMessageText(pMessage->message->message)); if (!szMessageText.IsEmpty()) { - PROTORECVEVENT pre = {}; - pre.timestamp = pMessage->message->messagetimestamp; - pre.szMessage = szMessageText.GetBuffer(); - pre.szMsgId = pMessage->message->key->id; - pre.flags = PREF_CREATEREAD; - if (pMessage->message->key->fromme) - pre.flags |= PREF_SENT; - ProtoChainRecvMsg(pUser->hContact, &pre); + auto *key = pMessage->message->key; + if (pUser->bIsGroupChat) { + GCEVENT gce = {m_szModuleName, 0, GC_EVENT_MESSAGE}; + gce.dwFlags = GCEF_UTF8; + gce.pszID.a = pUser->szId; + gce.pszUID.a = key->participant; + gce.bIsMe = key->fromme; + gce.pszText.a = szMessageText.GetBuffer(); + gce.time = pMessage->message->messagetimestamp; + Chat_Event(&gce); + } + else { + PROTORECVEVENT pre = {}; + pre.timestamp = pMessage->message->messagetimestamp; + pre.szMessage = szMessageText.GetBuffer(); + pre.szMsgId = key->id; + pre.flags = PREF_CREATEREAD; + if (key->fromme) + pre.flags |= PREF_SENT; + ProtoChainRecvMsg(pUser->hContact, &pre); + } } } } diff --git a/protocols/WhatsApp/src/message.cpp b/protocols/WhatsApp/src/message.cpp index 4b002a3c64..32d42cad3d 100644 --- a/protocols/WhatsApp/src/message.cpp +++ b/protocols/WhatsApp/src/message.cpp @@ -205,15 +205,27 @@ void WhatsAppProto::ProcessMessage(WAMSG type, const Wa__WebMessageInfo &msg) if (pUser) { CMStringA szMessageText(GetMessageText(body)); if (!szMessageText.IsEmpty()) { - PROTORECVEVENT pre = {}; - pre.timestamp = timestamp; - pre.szMessage = szMessageText.GetBuffer(); - pre.szMsgId = msgId; - if (type.bOffline) - pre.flags |= PREF_CREATEREAD; - if (key->fromme) - pre.flags |= PREF_SENT; - ProtoChainRecvMsg(pUser->hContact, &pre); + if (pUser->bIsGroupChat) { + GCEVENT gce = {m_szModuleName, 0, GC_EVENT_MESSAGE}; + gce.dwFlags = GCEF_UTF8; + gce.pszID.a = pUser->szId; + gce.pszUID.a = participant; + gce.bIsMe = key->fromme; + gce.pszText.a = szMessageText.GetBuffer(); + gce.time = timestamp; + Chat_Event(&gce); + } + else { + PROTORECVEVENT pre = {}; + pre.timestamp = timestamp; + pre.szMessage = szMessageText.GetBuffer(); + pre.szMsgId = msgId; + if (type.bOffline) + pre.flags |= PREF_CREATEREAD; + if (key->fromme) + pre.flags |= PREF_SENT; + ProtoChainRecvMsg(pUser->hContact, &pre); + } } } -- cgit v1.2.3