From 8e2515105956ffde5915379348d7df94d4e3f06b Mon Sep 17 00:00:00 2001 From: ElzorFox Date: Mon, 10 Jun 2019 19:02:55 +0500 Subject: VKontakte: more logical order of processing parts of messages --- protocols/VKontakte/src/vk_messages.cpp | 58 ++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 27 deletions(-) (limited to 'protocols/VKontakte/src') diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index a83c5661c7..dbf4104d81 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -244,33 +244,6 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe int isRead = jnMsg["read_state"].as_int(); int uid = jnMsg["user_id"].as_int(); - const JSONNode &jnFwdMessages = jnMsg["fwd_messages"]; - if (jnFwdMessages) { - CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, m_vkOptions.BBCForAttachments()); - if (!wszBody.IsEmpty()) - wszFwdMessages = L"\n" + wszFwdMessages; - wszBody += wszFwdMessages; - } - - CMStringW wszBodyNoAttachments = wszBody; - - CMStringW wszAttachmentDescr; - const JSONNode &jnAttachments = jnMsg["attachments"]; - if (jnAttachments) { - wszAttachmentDescr = GetAttachmentDescr(jnAttachments, m_vkOptions.BBCForAttachments()); - - if (wszAttachmentDescr == L"== FilterAudioMessages ==") - continue; - - if (!wszBody.IsEmpty()) - wszBody += L"\n"; - wszBody += wszAttachmentDescr; - } - - if (m_vkOptions.bAddMessageLinkToMesWAtt && (jnAttachments || jnFwdMessages)) - wszBody += SetBBCString(TranslateT("Message link"), m_vkOptions.BBCForAttachments(), vkbbcUrl, - CMStringW(FORMAT, L"https://vk.com/im?sel=%d&msgid=%d", uid, mid)); - MCONTACT hContact = 0; int chat_id = jnMsg["chat_id"].as_int(); if (chat_id == 0) @@ -301,6 +274,37 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe continue; } + const JSONNode& jnFwdMessages = jnMsg["fwd_messages"]; + if (jnFwdMessages) { + CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, m_vkOptions.BBCForAttachments()); + if (!wszBody.IsEmpty()) + wszFwdMessages = L"\n" + wszFwdMessages; + wszBody += wszFwdMessages; + } + + CMStringW wszBodyNoAttachments = wszBody; + + + CMStringW wszAttachmentDescr; + const JSONNode &jnAttachments = jnMsg["attachments"]; + if (jnAttachments) { + wszAttachmentDescr = GetAttachmentDescr(jnAttachments, m_vkOptions.BBCForAttachments()); + + if (wszAttachmentDescr == L"== FilterAudioMessages ==") { + if (hContact && (mid > getDword(hContact, "lastmsgid", -1))) + setDword(hContact, "lastmsgid", mid); + continue; + } + + if (!wszBody.IsEmpty()) + wszBody += L"\n"; + wszBody += wszAttachmentDescr; + } + + if (m_vkOptions.bAddMessageLinkToMesWAtt && (jnAttachments || jnFwdMessages)) + wszBody += SetBBCString(TranslateT("Message link"), m_vkOptions.BBCForAttachments(), vkbbcUrl, + CMStringW(FORMAT, L"https://vk.com/im?sel=%d&msgid=%d", uid, mid)); + time_t update_time = (time_t)jnMsg["update_time"].as_int(); bool bEdited = (update_time != 0); -- cgit v1.2.3