summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2019-06-10 09:48:37 +0500
committerElzorFox <elzorfox@ya.ru>2019-06-10 09:48:37 +0500
commit9e9d67e4c600277cc073b706a8d7a158e71a2b2e (patch)
tree54cd650e3c28ca22666c7f361196b1a2c2f87476 /protocols
parentce537385656872ea2971bf5a28727a5d6cdc1cb6 (diff)
VKontakte: add hidden option ‘FilterAudioMessages’
Diffstat (limited to 'protocols')
-rw-r--r--protocols/VKontakte/src/misc.cpp14
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp4
-rw-r--r--protocols/VKontakte/src/vk_history.cpp6
-rw-r--r--protocols/VKontakte/src/vk_messages.cpp4
-rw-r--r--protocols/VKontakte/src/vk_struct.cpp1
-rw-r--r--protocols/VKontakte/src/vk_struct.h1
6 files changed, 27 insertions, 3 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index d0b75e0e6f..4765e129a3 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -1118,6 +1118,9 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
if (!jnDoc)
continue;
+ if (jnDoc["type"].as_int() == 5 && m_vkOptions.bFilterAudioMessages)
+ return L"== FilterAudioMessages ==";
+
CMStringW wszTitle(jnDoc["title"].as_mstring());
CMStringW wszUrl(jnDoc["url"].as_mstring());
res.AppendFormat(L"%s: %s",
@@ -1154,6 +1157,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
debugLogA("CVkProto::GetAttachmentDescr SubAttachments");
CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC);
wszAttachmentDescr.Replace(L"\n", L"\n\t\t");
+ wszAttachmentDescr.Replace(L"== FilterAudioMessages ==", L"");
res += L"\n\t\t" + wszAttachmentDescr;
}
}
@@ -1164,6 +1168,7 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
debugLogA("CVkProto::GetAttachmentDescr SubAttachments");
CMStringW wszAttachmentDescr = GetAttachmentDescr(jnSubAttachments, iBBC);
wszAttachmentDescr.Replace(L"\n", L"\n\t");
+ wszAttachmentDescr.Replace(L"== FilterAudioMessages ==", L"");
res += L"\n\t" + wszAttachmentDescr;
}
}
@@ -1337,9 +1342,12 @@ CMStringW CVkProto::GetFwdMessages(const JSONNode &jnMessages, const JSONNode &j
const JSONNode &jnAttachments = jnMsg["attachments"];
if (jnAttachments) {
CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, iBBC == bbcNo ? iBBC : m_vkOptions.BBCForAttachments());
- if (!wszBody.IsEmpty())
- wszAttachmentDescr = L"\n" + wszAttachmentDescr;
- wszBody += wszAttachmentDescr;
+ if (wszAttachmentDescr != L"== FilterAudioMessages ==") {
+ if (!wszBody.IsEmpty())
+ wszAttachmentDescr = L"\n" + wszAttachmentDescr;
+
+ wszBody += wszAttachmentDescr;
+ }
}
wszBody.Replace(L"\n", L"\n\t");
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index ce8afc5a67..fc9c834ad1 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -287,6 +287,10 @@ void CVkProto::AppendChatMessage(int id, const JSONNode &jnMsg, const JSONNode &
const JSONNode &jnAttachments = jnMsg["attachments"];
if (jnAttachments) {
CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, bbcNo);
+
+ if (wszAttachmentDescr == L"== FilterAudioMessages ==")
+ return;
+
if (!wszBody.IsEmpty())
wszAttachmentDescr = L"\n" + wszAttachmentDescr;
wszBody += wszAttachmentDescr;
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp
index 2de3001185..b661b2e438 100644
--- a/protocols/VKontakte/src/vk_history.cpp
+++ b/protocols/VKontakte/src/vk_history.cpp
@@ -257,6 +257,12 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
const JSONNode &jnAttachments = jnMsg["attachments"];
if (jnAttachments) {
CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, m_vkOptions.BBCForAttachments());
+
+ if (wszAttachmentDescr == L"== FilterAudioMessages ==") {
+ count++;
+ continue;
+ }
+
if (!wszBody.IsEmpty())
wszAttachmentDescr = L"\n" + wszAttachmentDescr;
wszBody += wszAttachmentDescr;
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp
index 35156eedcf..a83c5661c7 100644
--- a/protocols/VKontakte/src/vk_messages.cpp
+++ b/protocols/VKontakte/src/vk_messages.cpp
@@ -258,6 +258,10 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
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;
diff --git a/protocols/VKontakte/src/vk_struct.cpp b/protocols/VKontakte/src/vk_struct.cpp
index 0a687ab270..8524d18538 100644
--- a/protocols/VKontakte/src/vk_struct.cpp
+++ b/protocols/VKontakte/src/vk_struct.cpp
@@ -198,6 +198,7 @@ CVKOptions::CVKOptions(PROTO_INTERFACE *proto) :
bLoadFullCList(proto, "LoadFullCList", false),
bShowVkDeactivateEvents(proto, "ShowVkDeactivateEvents", true),
bStickerBackground(proto, "StickerBackground", false),
+ bFilterAudioMessages(proto, "FilterAudioMessages", false),
bShowProtoMenuItem0(proto, "ShowProtoMenuItem0", true),
bShowProtoMenuItem1(proto, "ShowProtoMenuItem1", true),
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h
index 16e20217df..5b4609c681 100644
--- a/protocols/VKontakte/src/vk_struct.h
+++ b/protocols/VKontakte/src/vk_struct.h
@@ -297,6 +297,7 @@ struct CVKOptions {
CMOption<BYTE> bLoadSentAttachments;
CMOption<BYTE> bShowVkDeactivateEvents;
CMOption<BYTE> bStickerBackground;
+ CMOption<BYTE> bFilterAudioMessages;
CMOption<BYTE> bShowProtoMenuItem0;
CMOption<BYTE> bShowProtoMenuItem1;