summaryrefslogtreecommitdiff
path: root/protocols/WhatsApp/src/message.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-10-31 20:20:16 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-10-31 20:20:16 +0300
commit476aa34eeec80dc9b1b15b48ef5db84501dcae42 (patch)
tree84dbc5fd64e397c48666c476f60c10572728578f /protocols/WhatsApp/src/message.cpp
parent61cb1c1445b8ebfef08c864f0062baa68390dd1a (diff)
WhatsApp: history sync processing
Diffstat (limited to 'protocols/WhatsApp/src/message.cpp')
-rw-r--r--protocols/WhatsApp/src/message.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/protocols/WhatsApp/src/message.cpp b/protocols/WhatsApp/src/message.cpp
index 84d863830a..74bead6695 100644
--- a/protocols/WhatsApp/src/message.cpp
+++ b/protocols/WhatsApp/src/message.cpp
@@ -210,17 +210,7 @@ void WhatsAppProto::ProcessMessage(WAMSG type, const Wa__WebMessageInfo &msg)
// 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;
-
+ CMStringA szMessageText(getMessageText(body));
if (!szMessageText.IsEmpty()) {
PROTORECVEVENT pre = {};
pre.timestamp = timestamp;
@@ -249,11 +239,24 @@ void WhatsAppProto::ProcessMessage(WAMSG type, const Wa__WebMessageInfo &msg)
break;
case WA__MESSAGE__PROTOCOL_MESSAGE__TYPE__APP_STATE_FATAL_EXCEPTION_NOTIFICATION:
- debugLogA("History sync notification");
m_impl.m_resyncApp.Stop();
m_impl.m_resyncApp.Start(10000);
break;
+ case WA__MESSAGE__PROTOCOL_MESSAGE__TYPE__HISTORY_SYNC_NOTIFICATION:
+ debugLogA("History sync notification");
+ if (auto *pHist = protoMsg->historysyncnotification) {
+ MBinBuffer buf(DownloadEncryptedFile(directPath2url(pHist->directpath), pHist->mediakey, "History"));
+ if (buf.data()) {
+ MBinBuffer inflate(unzip(unpadBuffer16(buf)));
+
+ proto::HistorySync sync(inflate);
+ if (sync)
+ ProcessHistorySync(sync);
+ }
+ }
+ break;
+
case WA__MESSAGE__PROTOCOL_MESSAGE__TYPE__REVOKE:
break;