summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-11-03 21:22:06 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-11-03 21:22:06 +0300
commit19188a13f7bfc07d453df5fe9d42a75a1b4dbe83 (patch)
tree3e8b6462dbcd52a550389f54e9c679eb3dcded3f
parent182c8806c47e927f8267e21a45242cb8e8d4f75b (diff)
WhatsApp: receiving group chats messages
-rw-r--r--protocols/WhatsApp/src/appsync.cpp29
-rw-r--r--protocols/WhatsApp/src/message.cpp30
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);
+ }
}
}