diff options
author | ElzorFox <elzorfox@ya.ru> | 2024-04-05 19:33:56 +0500 |
---|---|---|
committer | ElzorFox <elzorfox@ya.ru> | 2024-04-05 19:33:56 +0500 |
commit | 11db9bbe6aa2b7832c2b7896b1e0bb51b5530553 (patch) | |
tree | da3214eb45c4e595d5fd98e98c6e295bb8eeb2fd | |
parent | 8d9d3d3809dd91a14df619e58535c00ad8fc48e7 (diff) |
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
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 36 | ||||
-rw-r--r-- | protocols/VKontakte/src/version.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_chats.cpp | 34 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_feed.cpp | 13 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_files.cpp | 17 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_history.cpp | 6 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_messages.cpp | 12 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 12 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_struct.h | 3 |
9 files changed, 86 insertions, 49 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 364acc7a98..1d2f67b693 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -1101,7 +1101,7 @@ CMStringW CVkProto::SpanVKNotificationType(CMStringW& wszType, VKObjType& vkFeed return wszRes;
}
-CMStringW CVkProto::GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC)
+CMStringW CVkProto::GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC, MCONTACT hContact, VKMessageID_t iMessageId, bool bAsync)
{
CMStringW wszRes;
@@ -1146,7 +1146,7 @@ CMStringW CVkProto::GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC) vkSizes[iMaxSize].iSizeW,
vkSizes[iMaxSize].iSizeH
);
- wszPreviewLink = GetVkFileItem(vkSizes[iMaxSize].wszUrl);
+ wszPreviewLink = GetVkFileItem(vkSizes[iMaxSize].wszUrl, hContact, iMessageId, bAsync);
wszRes = SetBBCString(wszRes, bbcAdvanced, vkbbcImgE, (!wszPreviewLink.IsEmpty() ? wszPreviewLink : L""));
}
else {
@@ -1187,7 +1187,7 @@ CMStringW CVkProto::SetBBCString(LPCWSTR pwszString, BBCSupport iBBC, VKBBCType { vkbbcU, bbcAdvanced, L"[u]%s[/u]" },
{ vkbbcCode, bbcNo, L"%s" },
{ vkbbcCode, bbcBasic, L"%s" },
- { vkbbcCode, bbcAdvanced, L"[code]%s[/code]" },
+ { vkbbcCode, bbcAdvanced, m_vkOptions.bBBCNewStorySupport ? L"%s" : L"[code]%s[/code]"},
{ vkbbcImg, bbcNo, L"%s" },
{ vkbbcImg, bbcBasic, L"[img]%s[/img]" },
{ vkbbcImg, bbcAdvanced, L"[img]%s[/img]" },
@@ -1247,7 +1247,7 @@ CMStringW& CVkProto::ClearFormatNick(CMStringW& wszText) /////////////////////////////////////////////////////////////////////////////////////////
-CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport iBBC)
+CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport iBBC, MCONTACT hContact, VKMessageID_t iMessageId, bool bAsync)
{
debugLogA("CVkProto::GetAttachmentDescr");
CMStringW res;
@@ -1267,7 +1267,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport if (!jnPhoto)
continue;
- res += GetVkPhotoItem(jnPhoto, iBBC);
+ res += GetVkPhotoItem(jnPhoto, iBBC, hContact, iMessageId, bAsync);
}
else if (wszType == L"audio") {
const JSONNode& jnAudio = jnAttach["audio"];
@@ -1370,7 +1370,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport const JSONNode& jnSubAttachments = jnCopyHystoryItem["attachments"];
if (jnSubAttachments) {
debugLogA("CVkProto::GetAttachmentDescr SubAttachments");
- CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC);
+ CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC, hContact, iMessageId, bAsync);
wszAttachmentDescr.Replace(L"\n", L"\n\t\t");
wszAttachmentDescr.Replace(L"== FilterAudioMessages ==", L"");
res += L"\n\t\t" + wszAttachmentDescr;
@@ -1381,7 +1381,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport const JSONNode& jnSubAttachments = jnWall["attachments"];
if (jnSubAttachments) {
debugLogA("CVkProto::GetAttachmentDescr SubAttachments");
- CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC);
+ CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC, hContact, iMessageId, bAsync);
wszAttachmentDescr.Replace(L"\n", L"\n\t");
wszAttachmentDescr.Replace(L"== FilterAudioMessages ==", L"");
res += L"\n\t" + wszAttachmentDescr;
@@ -1418,7 +1418,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport const JSONNode& jnSubAttachments = jnWallReply["attachments"];
if (jnSubAttachments) {
debugLogA("CVkProto::GetAttachmentDescr SubAttachments");
- CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC);
+ CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC, hContact, iMessageId, bAsync);
wszAttachmentDescr.Replace(L"\n", L"\n\t");
wszAttachmentDescr.Replace(L"== FilterAudioMessages ==", L"");
res += L"\n\t" + wszAttachmentDescr;
@@ -1443,7 +1443,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport continue;
res += L"\n\t";
- res += GetVkPhotoItem(jnPhoto, iBBC);
+ res += GetVkPhotoItem(jnPhoto, iBBC, hContact, iMessageId, bAsync);
}
else if (wszStoryType == L"video") {
const JSONNode& jnVideo = jnStory["video"];
@@ -1545,7 +1545,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport res.AppendFormat(L"\n\t%s", SetBBCString(wszCaption, iBBC, vkbbcI).c_str());
if (jnLink["photo"])
- res.AppendFormat(L"\n\t%s", GetVkPhotoItem(jnLink["photo"], iBBC).c_str());
+ res.AppendFormat(L"\n\t%s", GetVkPhotoItem(jnLink["photo"], iBBC, hContact, iMessageId, bAsync).c_str());
if (!wszDescription.IsEmpty())
res.AppendFormat(L"\n\t%s", wszDescription.c_str());
@@ -1615,7 +1615,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport return res;
}
-CMStringW CVkProto::GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUsers, OBJLIST<CVkUserInfo>& vkUsers, BBCSupport iBBC)
+CMStringW CVkProto::GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUsers, OBJLIST<CVkUserInfo>& vkUsers, BBCSupport iBBC, bool bAsync)
{
VKUserID_t iUserId = jnMsg["from_id"].as_int();
CMStringW wszBody(jnMsg["text"].as_mstring());
@@ -1623,12 +1623,14 @@ CMStringW CVkProto::GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUser CVkUserInfo* vkUser = vkUsers.find((CVkUserInfo*)&iUserId);
CMStringW wszNick, wszUrl;
+ MCONTACT hContact = FindUser(iUserId);
+ VKMessageID_t iMessageId = jnMsg["id"].as_int();
+
if (vkUser) {
wszNick = vkUser->m_wszUserNick;
wszUrl = vkUser->m_wszLink;
}
else {
- MCONTACT hContact = FindUser(iUserId);
if (hContact || iUserId == m_iMyUserId)
wszNick = ptrW(db_get_wsa(hContact, m_szModuleName, "Nick"));
else
@@ -1644,7 +1646,7 @@ CMStringW CVkProto::GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUser const JSONNode& jnFwdMessages = jnMsg["fwd_messages"];
if (jnFwdMessages && !jnFwdMessages.empty()) {
- CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, iBBC == bbcNo ? iBBC : m_vkOptions.BBCForAttachments());
+ CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, iBBC == bbcNo ? iBBC : m_vkOptions.BBCForAttachments(), bAsync);
if (!wszBody.IsEmpty())
wszFwdMessages = L"\n" + wszFwdMessages;
wszBody += wszFwdMessages;
@@ -1652,7 +1654,7 @@ CMStringW CVkProto::GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUser const JSONNode& jnAttachments = jnMsg["attachments"];
if (jnAttachments && !jnAttachments.empty()) {
- CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, iBBC == bbcNo ? iBBC : m_vkOptions.BBCForAttachments());
+ CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, iBBC == bbcNo ? iBBC : m_vkOptions.BBCForAttachments(), hContact, iMessageId, bAsync);
if (wszAttachmentDescr != L"== FilterAudioMessages ==") {
if (!wszBody.IsEmpty())
wszAttachmentDescr = L"\n" + wszAttachmentDescr;
@@ -1675,7 +1677,7 @@ CMStringW CVkProto::GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUser }
-CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &jnFUsers, BBCSupport iBBC)
+CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &jnFUsers, BBCSupport iBBC, bool bAsync)
{
CMStringW res;
debugLogA("CVkProto::GetFwdMessages");
@@ -1703,10 +1705,10 @@ CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &j for (auto& jnMsg : jnMessages.as_array()) {
if (!res.IsEmpty())
res.AppendChar('\n');
- res += GetFwdMessage(jnMsg, jnFUsers, vkUsers, iBBC);
+ res += GetFwdMessage(jnMsg, jnFUsers, vkUsers, iBBC, bAsync);
}
else
- res = GetFwdMessage(jnMessages, jnFUsers, vkUsers, iBBC);
+ res = GetFwdMessage(jnMessages, jnFUsers, vkUsers, iBBC, bAsync);
res.AppendChar('\n');
vkUsers.destroy();
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index a920ddfc9d..bed1b164f1 100644 --- a/protocols/VKontakte/src/version.h +++ b/protocols/VKontakte/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 16
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>
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;
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp index b3bc4e5424..5260774e7a 100644 --- a/protocols/VKontakte/src/vk_feed.cpp +++ b/protocols/VKontakte/src/vk_feed.cpp @@ -172,9 +172,11 @@ CVKNewsItem* CVkProto::GetVkNewsItem(const JSONNode &jnItem, OBJLIST<CVkUserInfo vkNewsItem->bIsGroup = vkNewsItem->vkUser->m_bIsGroup;
vkNewsItem->tDate = jnItem["date"].as_int();
+ MCONTACT hNewsContact = FindUser(VK_FEED_USER, true);
+
if (!wszText.IsEmpty())
wszText += L"\n";
-
+
debugLogW(L"CVkProto::GetVkNewsItem %d %d %s", iSourceId, iPostId, vkNewsItem->wszType.c_str());
if (vkNewsItem->wszType == L"photo_tag") {
@@ -186,7 +188,7 @@ CVKNewsItem* CVkProto::GetVkNewsItem(const JSONNode &jnItem, OBJLIST<CVkUserInfo wszText = TranslateT("User was tagged in these photos:");
wszPopupText = wszText + TranslateT("(photos)");
for (auto &it : jnPhotoItems)
- wszText += L"\n" + GetVkPhotoItem(it, m_vkOptions.BBCForNews());
+ wszText += L"\n" + GetVkPhotoItem(it, m_vkOptions.BBCForNews(), hNewsContact, -1, false);
}
}
}
@@ -199,7 +201,7 @@ CVKNewsItem* CVkProto::GetVkNewsItem(const JSONNode &jnItem, OBJLIST<CVkUserInfo if (jnPhotoItems) {
wszPopupText += TranslateT("(photos)");
for (auto &jnPhotoItem : jnPhotoItems) {
- wszText += GetVkPhotoItem(jnPhotoItem, m_vkOptions.BBCForNews()) + L"\n";
+ wszText += GetVkPhotoItem(jnPhotoItem, m_vkOptions.BBCForNews(), hNewsContact, -1, false) + L"\n";
if (i == 0 && vkNewsItem->wszType == L"wall_photo") {
if (jnPhotoItem["post_id"]) {
bPostLink = true;
@@ -238,7 +240,7 @@ CVKNewsItem* CVkProto::GetVkNewsItem(const JSONNode &jnItem, OBJLIST<CVkUserInfo if (!wszPopupText.IsEmpty())
wszPopupText.AppendChar('\n');
wszPopupText += TranslateT("(attachments)");
- wszText += GetAttachmentDescr(jnAttachments, m_vkOptions.bUseBBCOnAttacmentsAsNews ? m_vkOptions.BBCForNews() : m_vkOptions.BBCForAttachments());
+ wszText += GetAttachmentDescr(jnAttachments, m_vkOptions.bUseBBCOnAttacmentsAsNews ? m_vkOptions.BBCForNews() : m_vkOptions.BBCForAttachments(), hNewsContact, -1, false);
}
}
@@ -328,9 +330,10 @@ CVKNewsItem* CVkProto::GetVkParent(const JSONNode &jnParent, VKObjType vkParentT return nullptr;
CVKNewsItem *vkNotificationItem = new CVKNewsItem();
+ MCONTACT hNewsContact = FindUser(VK_FEED_USER, true);
if (vkParentType == vkPhoto) {
- CMStringW wszPhoto = GetVkPhotoItem(jnParent, m_vkOptions.BBCForNews());
+ CMStringW wszPhoto = GetVkPhotoItem(jnParent, m_vkOptions.BBCForNews(), hNewsContact, -1, false);
VKUserID_t iOwnerId = jnParent["owner_id"].as_int();
int iId = jnParent["id"].as_int();
vkNotificationItem->wszId.AppendFormat(L"%d_%d", iOwnerId, iId);
diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp index 4cd9007fef..ecf3cd164f 100644 --- a/protocols/VKontakte/src/vk_files.cpp +++ b/protocols/VKontakte/src/vk_files.cpp @@ -17,17 +17,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h"
-CMStringW CVkProto::GetVkFileItem(CMStringW& _wszUrl, bool bAsync)
+CMStringW CVkProto::GetVkFileItem(CMStringW& _wszUrl, MCONTACT hContact, VKMessageID_t /*iMessageId*/, bool bAsync)
{
wchar_t buf[MAX_PATH];
- File::GetReceivedFolder(0, buf, _countof(buf));
+ File::GetReceivedFolder(hContact, buf, _countof(buf));
- if (_wszUrl.IsEmpty())
+ debugLogW(L"CVkProto::GetVkFileItem: (%s) %d", buf, hContact);
+
+ if (_wszUrl.IsEmpty()) {
+ debugLogW(L"CVkProto::GetVkFileItem: url empty");
return _wszUrl;
+ }
- CMStringW wszUrl = _wszUrl;
+ CreateDirectoryTreeW(buf);
+ CMStringW wszUrl = _wszUrl;
wszUrl.Replace(L"\\", L"/");
if (int i = wszUrl.Find('?'))
@@ -63,12 +68,14 @@ CMStringW CVkProto::GetVkFileItem(CMStringW& _wszUrl, bool bAsync) return _wszUrl;
}
- FILE* out = _wfopen(wszUrl.c_str(), L"wb");
+ FILE* out = _wfopen(wszUrl.c_str(), L"wb+");
if (out) {
fwrite(reply->body, 1, reply->body.GetLength(), out);
fclose(out);
debugLogW(L"CVkProto::GetVkFileItem file %s saved", wszUrl.c_str());
}
+ else
+ debugLogW(L"CVkProto::GetVkFileItem error open file %s", wszUrl.c_str());
}
else
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index 7504b846e8..aa8d9c8a3f 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -251,7 +251,7 @@ void CVkProto::OnReceiveHistoryMessages(MHttpResponse *reply, AsyncHttpRequest * const JSONNode &jnFwdMessages = jnMsg["fwd_messages"];
if (jnFwdMessages && !jnFwdMessages.empty()) {
- CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, m_vkOptions.BBCForAttachments());
+ CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, m_vkOptions.BBCForAttachments(), true);
if (!wszBody.IsEmpty())
wszFwdMessages = L"\n" + wszFwdMessages;
wszBody += wszFwdMessages;
@@ -260,7 +260,7 @@ void CVkProto::OnReceiveHistoryMessages(MHttpResponse *reply, AsyncHttpRequest * const JSONNode& jnReplyMessages = jnMsg["reply_message"];
if (jnReplyMessages && !jnReplyMessages.empty())
if (m_vkOptions.bShowReplyInMessage) {
- CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, m_vkOptions.BBCForAttachments());
+ CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, m_vkOptions.BBCForAttachments(), true);
if (!wszBody.IsEmpty())
wszReplyMessages = L"\n" + wszReplyMessages;
wszBody += wszReplyMessages;
@@ -270,7 +270,7 @@ void CVkProto::OnReceiveHistoryMessages(MHttpResponse *reply, AsyncHttpRequest * const JSONNode &jnAttachments = jnMsg["attachments"];
if (jnAttachments && !jnAttachments.empty()) {
- CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, m_vkOptions.BBCForAttachments());
+ CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, m_vkOptions.BBCForAttachments(), hContact, iMessageId, true);
if (wszAttachmentDescr == L"== FilterAudioMessages ==") {
count++;
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index 6cb7180ec1..cfdb82145d 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -378,7 +378,7 @@ void CVkProto::OnReceiveMessages(MHttpResponse *reply, AsyncHttpRequest *pReq) const JSONNode& jnFwdMessages = jnMsg["fwd_messages"];
if (jnFwdMessages && !jnFwdMessages.empty()) {
- CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, m_vkOptions.BBCForAttachments());
+ CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, m_vkOptions.BBCForAttachments(), false);
if (!wszBody.IsEmpty())
wszFwdMessages = L"\n" + wszFwdMessages;
wszBody += wszFwdMessages;
@@ -387,7 +387,7 @@ void CVkProto::OnReceiveMessages(MHttpResponse *reply, AsyncHttpRequest *pReq) const JSONNode& jnReplyMessages = jnMsg["reply_message"];
if (jnReplyMessages && !jnReplyMessages.empty())
if (m_vkOptions.bShowReplyInMessage) {
- CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, m_vkOptions.BBCForAttachments());
+ CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, m_vkOptions.BBCForAttachments(), false);
if (!wszBody.IsEmpty())
wszReplyMessages = L"\n" + wszReplyMessages;
wszBody += wszReplyMessages;
@@ -400,7 +400,7 @@ void CVkProto::OnReceiveMessages(MHttpResponse *reply, AsyncHttpRequest *pReq) CMStringW wszAttachmentDescr;
const JSONNode& jnAttachments = jnMsg["attachments"];
if (jnAttachments && !jnAttachments.empty()) {
- wszAttachmentDescr = GetAttachmentDescr(jnAttachments, m_vkOptions.BBCForAttachments());
+ wszAttachmentDescr = GetAttachmentDescr(jnAttachments, m_vkOptions.BBCForAttachments(), hContact, iMessageId, false);
if (wszAttachmentDescr == L"== FilterAudioMessages ==") {
if (hContact && (iMessageId > ReadQSWord(hContact, "lastmsgid", -1)))
@@ -418,7 +418,7 @@ void CVkProto::OnReceiveMessages(MHttpResponse *reply, AsyncHttpRequest *pReq) CMStringW(FORMAT, L"https://vk.com/im?sel=%d&msgid=%d", iUserId, iMessageId));
VKMessageID_t iReadMsg = ReadQSWord(hContact, "in_read", 0);
- int isRead = (iMessageId <= iReadMsg);
+ bool bIsRead = (iMessageId <= iReadMsg);
time_t tUpdateTime = (time_t)jnMsg["update_time"].as_int();
bool bEdited = (tUpdateTime != 0);
@@ -442,7 +442,7 @@ void CVkProto::OnReceiveMessages(MHttpResponse *reply, AsyncHttpRequest *pReq) DB::EventInfo dbei;
- if (isRead && bUseServerReadFlag)
+ if (bIsRead && bUseServerReadFlag)
dbei.flags |= DBEF_READ;
if (isOut)
@@ -459,7 +459,7 @@ void CVkProto::OnReceiveMessages(MHttpResponse *reply, AsyncHttpRequest *pReq) debugLogA("CVkProto::OnReceiveMessages szReplyId = %s", szReplyId);
}
- debugLogA("CVkProto::OnReceiveMessages mid = %d, datetime = %d, isOut = %d, isRead = %d, iUserId = %d, Edited = %d", iMessageId, tDateTime, isOut, isRead, iUserId, (int)bEdited);
+ debugLogA("CVkProto::OnReceiveMessages mid = %d, datetime = %d, isOut = %d, isRead = %d, iUserId = %d, Edited = %d", iMessageId, tDateTime, isOut, (int)bIsRead, iUserId, (int)bEdited);
if (!IsMessageExist(iMessageId, vkALL) || bEdited || szReplyId) {
debugLogA("CVkProto::OnReceiveMessages new or edited message");
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 198bad53c5..e728621b22 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -289,7 +289,7 @@ private: //==== Files Download ================================================================
- CMStringW CVkProto::GetVkFileItem(CMStringW& wszUrl, bool bAsync = false);
+ CMStringW CVkProto::GetVkFileItem(CMStringW& wszUrl, MCONTACT hContact, VKMessageID_t iMessageId, bool bAsync);
void OnGetVkFileItem(MHttpResponse* reply, AsyncHttpRequest* pReq);
//==== Files Upload ==================================================================
@@ -389,12 +389,12 @@ private: char* GetStickerId(const char *szMsg, int& iStickerid);
CMStringA GetAttachmentsFromMessage(const char * szMsg);
CMStringW SpanVKNotificationType(CMStringW& wszType, VKObjType& vkFeedback, VKObjType& vkParent);
- CMStringW GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC);
+ CMStringW GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC, MCONTACT hContact, VKMessageID_t iMessageId, bool bAsync);
CMStringW SetBBCString(LPCWSTR wszString, BBCSupport iBBC, VKBBCType bbcType, LPCWSTR wszAddString = nullptr);
CMStringW& ClearFormatNick(CMStringW& wszText);
- CMStringW GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport iBBC);
- CMStringW GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUsers, OBJLIST<CVkUserInfo>& vkUsers, BBCSupport iBBC);
- CMStringW GetFwdMessages(const JSONNode &jnMessages, const JSONNode &jnFUsers, BBCSupport iBBC);
+ CMStringW GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport iBBC, MCONTACT hContact, VKMessageID_t iMessageId, bool bAsync);
+ CMStringW GetFwdMessage(const JSONNode& jnMsg, const JSONNode& jnFUsers, OBJLIST<CVkUserInfo>& vkUsers, BBCSupport iBBC, bool bAsync);
+ CMStringW GetFwdMessages(const JSONNode &jnMessages, const JSONNode &jnFUsers, BBCSupport iBBC, bool bAsync);
void SetInvisible(MCONTACT hContact);
CMStringW RemoveBBC(CMStringW& wszSrc);
void AddVkDeactivateEvent(MCONTACT hContact, CMStringW & wszType);
@@ -427,7 +427,7 @@ private: CVkChatInfo* AppendConversationChat(VKUserID_t iChatId, const JSONNode& jnItem);
void SetChatTitle(CVkChatInfo *cc, LPCWSTR wszTopic);
void AppendChatConversationMessage(VKUserID_t iChatId, const JSONNode& jnMsg, const JSONNode& jnFUsers, bool bIsHistory);
- void AppendChatMessage(CVkChatInfo* vkChatInfo, VKMessageID_t iMessageId, VKMessageID_t iReplyMsgId, VKUserID_t iUserId, time_t tMsgTime, LPCWSTR pwszBody, bool bIsHistory, bool bIsAction = false);
+ void AppendChatMessage(CVkChatInfo* vkChatInfo, VKMessageID_t iMessageId, VKMessageID_t iReplyMsgId, VKUserID_t iUserId, time_t tMsgTime, LPCWSTR pwszBody, bool bIsHistory, bool bIsRead, bool bIsAction = false);
void RetrieveChatInfo(CVkChatInfo*);
void OnReceiveChatInfo(MHttpResponse*, AsyncHttpRequest*);
void OnSendChatMsg(MHttpResponse*, AsyncHttpRequest*);
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h index e6e2e42f67..6bd59031db 100644 --- a/protocols/VKontakte/src/vk_struct.h +++ b/protocols/VKontakte/src/vk_struct.h @@ -94,6 +94,7 @@ struct CVkChatMessage : public MZeroedObject m_iUserId(0),
m_tDate(0),
m_bHistory(false),
+ m_bIsRead(false),
m_bIsAction(false)
{}
@@ -101,7 +102,7 @@ struct CVkChatMessage : public MZeroedObject VKMessageID_t m_iReplyMsgId;
VKUserID_t m_iUserId;
time_t m_tDate;
- bool m_bHistory, m_bIsAction;
+ bool m_bHistory, m_bIsRead, m_bIsAction;
ptrW m_wszBody;
};
|