summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/vk_feed.cpp
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2015-07-09 10:33:09 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2015-07-09 10:33:09 +0000
commit21c6c7a7cb65e25d55cce54b6e097c797b66f95e (patch)
tree0c8485de41cf9c550d8e7ed930bf8ba9f6b0b3e4 /protocols/VKontakte/src/vk_feed.cpp
parent3f42d3319d2a3e404db524428300ab0a8a9540b2 (diff)
VKontakte:
add locks for timer and vk_Instances fix mark messages as read in multiaccaunt configuration fix duplicate events and news version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@14514 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/vk_feed.cpp')
-rw-r--r--protocols/VKontakte/src/vk_feed.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/protocols/VKontakte/src/vk_feed.cpp b/protocols/VKontakte/src/vk_feed.cpp
index cf7978fcd5..487040ffb5 100644
--- a/protocols/VKontakte/src/vk_feed.cpp
+++ b/protocols/VKontakte/src/vk_feed.cpp
@@ -488,6 +488,10 @@ void CVkProto::RetrieveUnreadNews(time_t tLastNewsTime)
debugLogA("CVkProto::RetrieveUnreadNews");
if (!IsOnline())
return;
+
+ time_t tLastNewsReqTime = getDword("LastNewsReqTime", time(NULL) - 24 * 60 * 60);
+ if (time(NULL) - tLastNewsReqTime < 3 * 60)
+ return;
CMStringA szFilter;
szFilter = m_bNewsFilterPosts ? "post" : "";
@@ -523,14 +527,16 @@ void CVkProto::RetrieveUnreadNews(time_t tLastNewsTime)
return;
}
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/newsfeed.get.json", true, &CVkProto::OnReceiveUnreadNews)
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/newsfeed.get.json", true, &CVkProto::OnReceiveUnreadNews))
<< INT_PARAM("count", 100)
<< INT_PARAM("return_banned", m_bNewsSourceIncludeBanned ? 1 : 0)
<< INT_PARAM("max_photos", m_iMaxLoadNewsPhoto)
<< INT_PARAM("start_time", tLastNewsTime + 1)
<< CHAR_PARAM("filters", szFilter)
<< CHAR_PARAM("source_ids", szSource)
- << VER_API);
+ << VER_API;
+
+ setDword("LastNewsReqTime", (DWORD)time(NULL));
}
static int sttCompareVKNewsItems(const CVKNewsItem *p1, const CVKNewsItem *p2)
@@ -554,6 +560,7 @@ static int sttCompareVKNotificationItems(const CVKNewsItem *p1, const CVKNewsIte
void CVkProto::OnReceiveUnreadNews(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
debugLogA("CVkProto::OnReceiveUnreadNews %d", reply->resultCode);
+ db_unset(NULL, m_szModuleName, "LastNewsReqTime");
if (reply->resultCode != 200)
return;
@@ -602,14 +609,20 @@ void CVkProto::RetrieveUnreadNotifications(time_t tLastNotificationsTime)
if (!IsOnline())
return;
+ time_t tLastNotificationsReqTime = getDword("LastNotificationsReqTime", time(NULL) - 24 * 60 * 60);
+ if (time(NULL) - tLastNotificationsReqTime < 3 * 60)
+ return;
+
CMString code;
code.AppendFormat(_T("return{\"notifications\":API.notifications.get({\"count\": 100, \"start_time\":%d})%s"),
(LONG)(tLastNotificationsTime + 1),
m_bNotificationFilterInvites ? _T(",\"groupinvates\":API.groups.getInvites({\"extended\":1})};") : _T("};"));
- Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveUnreadNotifications)
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.json", true, &CVkProto::OnReceiveUnreadNotifications))
<< TCHAR_PARAM("code", code)
- << VER_API);
+ << VER_API;
+
+ setDword("LastNotificationsReqTime", (DWORD)time(NULL));
}
bool CVkProto::FilterNotification(CVKNewsItem* vkNotificationItem, bool& isCommented)
@@ -648,6 +661,7 @@ void CVkProto::NotificationMarkAsViewed()
void CVkProto::OnReceiveUnreadNotifications(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
{
debugLogA("CVkProto::OnReceiveUnreadNotifications %d", reply->resultCode);
+ db_unset(NULL, m_szModuleName, "LastNotificationsReqTime");
if (reply->resultCode != 200)
return;