From 11db9bbe6aa2b7832c2b7896b1e0bb51b5530553 Mon Sep 17 00:00:00 2001 From: ElzorFox Date: Fri, 5 Apr 2024 19:33:56 +0500 Subject: VKontakte: add edited message support for muc message async download images for history sync fix download directory vars no [code] bbc for newstory version bump --- protocols/VKontakte/src/vk_chats.cpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'protocols/VKontakte/src/vk_chats.cpp') diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index fc8cade822..be646621a4 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -376,7 +376,7 @@ void CVkProto::AppendChatConversationMessage(VKUserID_t iChatId, const JSONNode& const JSONNode& jnFwdMessages = jnMsg["fwd_messages"]; if (jnFwdMessages && !jnFwdMessages.empty()) { - CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, bbcNo); + CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, bbcNo, vkChatInfo->m_bHistoryRead); if (!wszBody.IsEmpty()) wszFwdMessages = L"\n" + wszFwdMessages; wszBody += wszFwdMessages; @@ -385,7 +385,7 @@ void CVkProto::AppendChatConversationMessage(VKUserID_t iChatId, const JSONNode& const JSONNode& jnReplyMessages = jnMsg["reply_message"]; if (jnReplyMessages && !jnReplyMessages.empty()) { if (m_vkOptions.bShowReplyInMessage) { - CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, bbcNo); + CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, bbcNo, vkChatInfo->m_bHistoryRead); if (!wszBody.IsEmpty()) wszReplyMessages = L"\n" + wszReplyMessages; wszBody += wszReplyMessages; @@ -396,7 +396,7 @@ void CVkProto::AppendChatConversationMessage(VKUserID_t iChatId, const JSONNode& const JSONNode& jnAttachments = jnMsg["attachments"]; if (jnAttachments && !jnAttachments.empty()) { - CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, bbcNo); + CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, bbcNo, vkChatInfo->m_si->hContact, iMessageId, vkChatInfo->m_bHistoryRead); if (wszAttachmentDescr == L"== FilterAudioMessages ==") return; @@ -406,6 +406,29 @@ void CVkProto::AppendChatConversationMessage(VKUserID_t iChatId, const JSONNode& wszBody += wszAttachmentDescr; } + VKMessageID_t iReadMsg = ReadQSWord(vkChatInfo->m_si->hContact, "in_read", 0); + bool bIsRead = (iMessageId <= iReadMsg); + + time_t tUpdateTime = (time_t)jnMsg["update_time"].as_int(); + bool bEdited = (tUpdateTime != 0); + + if (bEdited) { + wchar_t ttime[64]; + _locale_t locale = _create_locale(LC_ALL, ""); + _wcsftime_l(ttime, _countof(ttime), TranslateT("%x at %X"), localtime(&tUpdateTime), locale); + _free_locale(locale); + + wszBody = SetBBCString( + CMStringW(FORMAT, TranslateT("Edited message (updated %s):\n"), ttime), + m_vkOptions.BBCForAttachments(), vkbbcB) + + wszBody; + + CMStringW wszOldMsg; + if (GetMessageFromDb(iMessageId, tMsgTime, wszOldMsg)) + wszBody += SetBBCString(TranslateT("\nOriginal message:\n"), m_vkOptions.BBCForAttachments(), vkbbcB) + + wszOldMsg; + } + if (m_vkOptions.bAddMessageLinkToMesWAtt && ((jnAttachments && !jnAttachments.empty()) || (jnFwdMessages && !jnFwdMessages.empty()) || (jnReplyMessages && !jnReplyMessages.empty() && m_vkOptions.bShowReplyInMessage))) wszBody += SetBBCString(TranslateT("Message link"), bbcNo, vkbbcUrl, CMStringW(FORMAT, L"https://vk.com/im?sel=c%d&msgid=%d", vkChatInfo->m_iChatId, iMessageId)); @@ -500,12 +523,13 @@ void CVkProto::AppendChatConversationMessage(VKUserID_t iChatId, const JSONNode& vkChatMessage->m_tDate = tMsgTime; vkChatMessage->m_wszBody = mir_wstrdup(wszBody); vkChatMessage->m_bHistory = bIsHistory; + vkChatMessage->m_bIsRead = bIsRead; vkChatMessage->m_bIsAction = bIsAction; } } -void CVkProto::AppendChatMessage(CVkChatInfo* vkChatInfo, VKMessageID_t iMessageId, VKMessageID_t iReplyMsgId, VKUserID_t iUserId, time_t tMsgTime, LPCWSTR pwszBody, bool bIsHistory, bool bIsAction) +void CVkProto::AppendChatMessage(CVkChatInfo* vkChatInfo, VKMessageID_t iMessageId, VKMessageID_t iReplyMsgId, VKUserID_t iUserId, time_t tMsgTime, LPCWSTR pwszBody, bool bIsHistory, bool bIsRead, bool bIsAction) { debugLogA("CVkProto::AppendChatMessage2"); @@ -551,7 +575,7 @@ void CVkProto::AppendChatMessage(CVkChatInfo* vkChatInfo, VKMessageID_t iMessage dbei.pBlob = pszBody; if (iUserId == m_iMyUserId) dbei.flags |= DBEF_SENT; - if (bIsHistory) + if (bIsHistory || bIsRead) dbei.flags |= DBEF_READ; dbei.szUserId = pszNick; -- cgit v1.2.3