summaryrefslogtreecommitdiff
path: root/protocols/WhatsApp/src/message.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-10-30 13:16:07 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-10-30 13:16:07 +0300
commit96d5125d05d6ee41c567e8380608c2706d21656b (patch)
tree9b96a14b91ec5540e8c5d9f1c662151ca01e895f /protocols/WhatsApp/src/message.cpp
parentecb2a3bb4c42ca47ba0ce8e405d5a47aa899b64c (diff)
WhatsApp: extended message processing
Diffstat (limited to 'protocols/WhatsApp/src/message.cpp')
-rw-r--r--protocols/WhatsApp/src/message.cpp37
1 files changed, 25 insertions, 12 deletions
diff --git a/protocols/WhatsApp/src/message.cpp b/protocols/WhatsApp/src/message.cpp
index 3ae999fcd2..84d863830a 100644
--- a/protocols/WhatsApp/src/message.cpp
+++ b/protocols/WhatsApp/src/message.cpp
@@ -196,7 +196,7 @@ void WhatsAppProto::ProcessMessage(WAMSG type, const Wa__WebMessageInfo &msg)
auto *participant = key->participant;
auto *chatId = key->remotejid;
auto *msgId = key->id;
-
+
WAUser *pUser = FindUser(chatId);
if (pUser == nullptr) {
if (type.bPrivateChat)
@@ -208,17 +208,30 @@ void WhatsAppProto::ProcessMessage(WAMSG type, const Wa__WebMessageInfo &msg)
if (!bFromMe && msg.pushname && pUser && !pUser->bIsGroupChat)
setUString(pUser->hContact, "Nick", msg.pushname);
- // try to extract some text
- if (mir_strlen(body->conversation)) {
- PROTORECVEVENT pre = {};
- pre.timestamp = timestamp;
- pre.szMessage = body->conversation;
- pre.szMsgId = msgId;
- if (type.bOffline)
- pre.flags |= PREF_CREATEREAD;
- if (bFromMe)
- pre.flags |= PREF_SENT;
- ProtoChainRecvMsg(pUser->hContact, &pre);
+ // try to extract some text
+ if (pUser) {
+ CMStringA szMessageText;
+ if (auto *pExt = body->extendedtextmessage) {
+ if (pExt->contextinfo && pExt->contextinfo->quotedmessage)
+ szMessageText.AppendFormat("> %s\n\n", pExt->contextinfo->quotedmessage->conversation);
+
+ if (pExt->text)
+ szMessageText.Append(pExt->text);
+ }
+ else if (mir_strlen(body->conversation))
+ szMessageText = body->conversation;
+
+ if (!szMessageText.IsEmpty()) {
+ PROTORECVEVENT pre = {};
+ pre.timestamp = timestamp;
+ pre.szMessage = szMessageText.GetBuffer();
+ pre.szMsgId = msgId;
+ if (type.bOffline)
+ pre.flags |= PREF_CREATEREAD;
+ if (bFromMe)
+ pre.flags |= PREF_SENT;
+ ProtoChainRecvMsg(pUser->hContact, &pre);
+ }
}
if (body->protocolmessage) {