From 476aa34eeec80dc9b1b15b48ef5db84501dcae42 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 31 Oct 2022 20:20:16 +0300 Subject: WhatsApp: history sync processing --- protocols/WhatsApp/src/message.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'protocols/WhatsApp/src/message.cpp') 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; -- cgit v1.2.3