From f094a3f336eee0b551b3ba3640272e4a944b32d7 Mon Sep 17 00:00:00 2001 From: ElzorFox Date: Tue, 24 Jun 2025 16:40:32 +0500 Subject: =?UTF-8?q?VKontakte:=20add=20hidden=20option=20=E2=80=98RepeatReq?= =?UTF-8?q?uestAfterEmptyFrame=E2=80=98=20(default=20false)=20for=20old=20?= =?UTF-8?q?behavior=20on=20users.get=20empty=20response=20add=20hidden=20o?= =?UTF-8?q?ption=20=E2=80=98LoadCListInterval=E2=80=99=20(default=201)=20f?= =?UTF-8?q?or=20interval=20between=20contacts=20status=20requests=20rename?= =?UTF-8?q?=20hidden=20option=20=E2=80=98TimeoutAfterUserGet=E2=80=99=20to?= =?UTF-8?q?=20=E2=80=98TimeoutForUserGet=E2=80=99=20more=20fix=20for=20?= =?UTF-8?q?=E2=80=99error=209=E2=80=99=20version=20bump?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/VKontakte/src/vk_thread.cpp | 49 +++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 14 deletions(-) (limited to 'protocols/VKontakte/src/vk_thread.cpp') diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index fe33329ad2..69548e32ea 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -118,7 +118,12 @@ static void CALLBACK VKUnsetTimer(void*) void CVkProto::OnTimerTic() { - RetrieveUsersInfo(true); + + if (++m_iLoadCListIntervalCounter >= m_vkOptions.iLoadCListInterval) { + RetrieveUsersInfo(true); + m_iLoadCListIntervalCounter = 0; + } + RetrieveUnreadEvents(); SetServerStatus(m_iDesiredStatus); } @@ -392,6 +397,8 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool bFlag, VKContactT int iNewStatus = (jnItem["online"].as_int() == 0) ? ID_STATUS_OFFLINE : ID_STATUS_ONLINE; setWord(hContact, "Status", iNewStatus); + + db_unset(hContact, m_szModuleName, "EmptyFrameOffline"); if (iNewStatus == ID_STATUS_ONLINE) { db_set_dw(hContact, "BuddyExpectator", "LastSeen", (uint32_t)time(0)); @@ -575,7 +582,13 @@ void CVkProto::RetrieveUsersFrameInfo(CMStringA& szUserIds, bool bFreeOffline, b if (!IsOnline() || szUserIds.IsEmpty()) return; - Push(new AsyncHttpRequest(this, REQUEST_POST, "/method/execute.RetrieveUsersFrameInfo", true, &CVkProto::OnReceiveUserFrameInfo) + Push(new AsyncHttpRequest(this, + REQUEST_POST, + "/method/execute.RetrieveUsersFrameInfo", + true, + &CVkProto::OnReceiveUserFrameInfo, + bFreeOffline ? AsyncHttpRequest::rpLowCListEvents : AsyncHttpRequest::rpMedium + ) << CHAR_PARAM("userids", szUserIds) << CHAR_PARAM("fields", (bFreeOffline ? "online,status,can_write_private_message" : szFieldsName)) << INT_PARAM("norepeat", (int)bRepeat) @@ -606,13 +619,17 @@ void CVkProto::OnReceiveUserFrameInfo(MHttpResponse* reply, AsyncHttpRequest* pR mir_free(pReq->pUserInfo); } - if (!jnResponse["norepeat"].as_bool() && jnResponse["usercount"].as_int() == 0) { + bool bEmptyFrame = !jnResponse["norepeat"].as_bool() && jnResponse["usercount"].as_int() == 0; + + + + if (bEmptyFrame && m_vkOptions.bRepeatRequestAfterEmptyFrame) { Sleep(5000); RetrieveUsersFrameInfo(szUserIds, true, false, true); return; } - - LIST arContacts(10, PtrKeySortT); + + LIST arContacts(100, PtrKeySortT); for (auto& hContact : AccContacts()) if (!isChatRoom(hContact) && !IsGroupUser(hContact)) { @@ -642,20 +659,24 @@ void CVkProto::OnReceiveUserFrameInfo(MHttpResponse* reply, AsyncHttpRequest* pR if (iUserId == m_iMyUserId || iUserId == VK_FEED_USER) continue; - int iContactStatus = getWord(cc, "Status", ID_STATUS_OFFLINE); - - if ((iContactStatus == ID_STATUS_ONLINE) - || (iContactStatus == ID_STATUS_INVISIBLE && time(0) - getDword(cc, "InvisibleTS", 0) >= m_vkOptions.iInvisibleInterval * 60LL)) { - setWord(cc, "Status", ID_STATUS_OFFLINE); - SetMirVer(cc, -1); - db_unset(cc, m_szModuleName, "ListeningTo"); + if (getBool(cc, "EmptyFrameOffline")) { + int iContactStatus = getWord(cc, "Status", ID_STATUS_OFFLINE); + if ((iContactStatus == ID_STATUS_ONLINE) + || (iContactStatus == ID_STATUS_INVISIBLE && time(0) - getDword(cc, "InvisibleTS", 0) >= m_vkOptions.iInvisibleInterval * 60LL)) { + setWord(cc, "Status", ID_STATUS_OFFLINE); + SetMirVer(cc, -1); + db_unset(cc, m_szModuleName, "ListeningTo"); + } + db_unset(cc, m_szModuleName, "EmptyFrameOffline"); } + else + setByte(cc, "EmptyFrameOffline", 1); } arContacts.destroy(); - if (m_vkOptions.iTimeoutAfterUserGet) // for 'error 9' fix - Sleep(m_vkOptions.iTimeoutAfterUserGet > 5000 ? 5000 : m_vkOptions.iTimeoutAfterUserGet); + if (m_vkOptions.iTimeoutForUserGet) // for 'error 9' fix + Sleep(m_vkOptions.iTimeoutForUserGet > 60000 ? 5000 : m_vkOptions.iTimeoutForUserGet); const JSONNode& jnRequests = jnResponse["requests"]; if (!jnRequests) -- cgit v1.2.3