summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/vk_feed.cpp
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2015-03-16 10:52:18 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2015-03-16 10:52:18 +0000
commit927f7544d4639e95929da0827d73a830caf40667 (patch)
tree4114b60330f28ac1c0618a4d1131ed6b04c712a8 /protocols/VKontakte/src/vk_feed.cpp
parente157b8ecc9d3c75d7b7aef9f59ce69975d702d1d (diff)
VKontakte:
add ‘Mark notification as viewed on receive’ option version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@12414 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/vk_feed.cpp')
-rw-r--r--protocols/VKontakte/src/vk_feed.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp
index de43af6405..abe233451a 100644
--- a/protocols/VKontakte/src/vk_feed.cpp
+++ b/protocols/VKontakte/src/vk_feed.cpp
@@ -543,22 +543,38 @@ void CVkProto::RetrieveUnreadNotifications(time_t tLastNotificationsTime)
<< VER_API);
}
-bool CVkProto::FilterNotification(CVKNewsItem* vkNotificationItem)
+bool CVkProto::FilterNotification(CVKNewsItem* vkNotificationItem, bool& isCommented)
{
+ isCommented = false;
if (vkNotificationItem->vkParentType == vkNull)
return false;
if (vkNotificationItem->tszType == _T("mention_comments")
|| vkNotificationItem->tszType == _T("mention_comment_photo")
- || vkNotificationItem->tszType == _T("mention_comment_video"))
+ || vkNotificationItem->tszType == _T("mention_comment_video")){
+ isCommented = true;
return m_bNotificationFilterMentions;
+ }
bool result = (vkNotificationItem->vkFeedbackType == vkUsers && m_bNotificationFilterLikes);
result = (vkNotificationItem->vkFeedbackType == vkCopy && m_bNotificationFilterReposts) || result;
result = (vkNotificationItem->vkFeedbackType == vkComment && m_bNotificationFilterComments) || result;
+
+ isCommented = (vkNotificationItem->vkFeedbackType == vkComment);
+
return result;
}
+void CVkProto::NotificationMarkAsViewed()
+{
+ debugLogA("CVkProto::NotificationMarkAsViewed");
+ if (!IsOnline())
+ return;
+
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/notifications.markAsViewed.json", true, &CVkProto::OnReceiveSmth)
+ << VER_API);
+}
+
void CVkProto::OnReceiveUnreadNotifications(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
debugLogA("CVkProto::OnReceiveUnreadNotifications %d", reply->resultCode);
@@ -588,11 +604,17 @@ void CVkProto::OnReceiveUnreadNotifications(NETLIBHTTPREQUEST *reply, AsyncHttpR
delete vkNotificationItem;
}
+ bool bNotificationCommentAdded = false;
+ bool bNotificationComment = false;
for (int i = 0; i < vkNotification.getCount(); i++)
- if (FilterNotification(&vkNotification[i]))
+ if (FilterNotification(&vkNotification[i], bNotificationComment)) {
AddFeedEvent(vkNotification[i].tszText, vkNotification[i].tDate);
+ bNotificationCommentAdded = bNotificationComment || bNotificationCommentAdded;
+ }
setDword("LastNotificationsTime", time(NULL));
+ if (m_bNotificationsMarkAsViewed && bNotificationCommentAdded)
+ NotificationMarkAsViewed();
vkNotification.destroy();
vkUsers.destroy();
}