From 1d03e3af5e2b5f1ab80e250b11323a2c27fc1bcf Mon Sep 17 00:00:00 2001 From: ElzorFox Date: Fri, 1 Dec 2023 12:12:28 +0500 Subject: VKontakte: update VK API version to 5.199 version bump --- protocols/VKontakte/src/version.h | 2 +- protocols/VKontakte/src/vk.h | 2 +- protocols/VKontakte/src/vk_chats.cpp | 2 +- protocols/VKontakte/src/vk_files.cpp | 2 +- protocols/VKontakte/src/vk_thread.cpp | 6 +++++- protocols/VKontakte/src/vkjs.js | 39 ++++++++++++++++++++++++++++++++--- 6 files changed, 45 insertions(+), 8 deletions(-) (limited to 'protocols/VKontakte/src') diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index a59d576a65..1af511c2ae 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 15 -#define __BUILD_NUM 1 +#define __BUILD_NUM 2 #include diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h index e57b21b865..56f24f8c99 100644 --- a/protocols/VKontakte/src/vk.h +++ b/protocols/VKontakte/src/vk.h @@ -88,7 +88,7 @@ along with this program. If not, see . #define VK_USER_DEACTIVATE_ACTION 9321 -#define VK_API_VER "5.131" +#define VK_API_VER "5.199" #define VER_API CHAR_PARAM("v", VK_API_VER) #define VK_FEED_USER 2147483647L diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 6d6a84db99..5e6f208b76 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -191,7 +191,7 @@ void CVkProto::RetrieveChatInfo(CVkChatInfo *cc) Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.RetrieveChatInfo", true, &CVkProto::OnReceiveChatInfo) << INT_PARAM("chatid", cc->m_iChatId) - << INT_PARAM("func_v", cc->m_bHistoryRead ? 1 : 3) + << INT_PARAM("func_v", cc->m_bHistoryRead ? 1 : 4) )->pUserInfo = cc; } diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp index c376c9ce59..5c83372d51 100644 --- a/protocols/VKontakte/src/vk_files.cpp +++ b/protocols/VKontakte/src/vk_files.cpp @@ -383,7 +383,7 @@ void CVkProto::OnReciveUploadFile(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR } pMsgReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh); - pMsgReq << INT_PARAM("user_id", iUserId); + pMsgReq << INT_PARAM("peer_id", iUserId); pMsgReq->pUserInfo = new CVkSendMsgParam(fup->hContact, fup); } diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index c7a1e5259d..393a215079 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -813,7 +813,11 @@ void CVkProto::OnReceiveGroupInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR if (!jnResponse) return; - for (auto &jnItem : jnResponse) { + const JSONNode& jnGroups = jnResponse["groups"]; + if (!jnGroups) + return; + + for (auto &jnItem : jnGroups) { VKUserID_t iGroupId = (-1)*jnItem["id"].as_int(); bool bIsMember = jnItem["is_member"].as_bool(); diff --git a/protocols/VKontakte/src/vkjs.js b/protocols/VKontakte/src/vkjs.js index 8f1ed1185f..86e189a89a 100644 --- a/protocols/VKontakte/src/vkjs.js +++ b/protocols/VKontakte/src/vkjs.js @@ -373,9 +373,42 @@ var MsgUsers = API.users.get({ "user_ids": ChatMsg.items@.from_id, "fields":"id, return { "info": Info, "users": ChatUsers, "msgs": ChatMsg, "fwd_users": FUsers + GUsers, "msgs_users": MsgUsers}; -var Info=API.messages.getChat({"chat_id": Args.chatid}); -var ChatUsers=API.messages.getChatUsers({"chat_id":Args.chatid,"fields":"id,first_name,last_name"}); -return {"info":Info,"users":ChatUsers}; +// ver 4 +var Info = API.messages.getChat({ "chat_id": Args.chatid }); +var PeerId = 2000000000 + parseInt(Args.chatid); +var ChatUsers = API.messages.getConversationMembers({ "peer_id": PeerId, "fields": "id,first_name,last_name" }); +var ChatMsg = API.messages.getHistory({ "peer_id": PeerId, "count": 20, "rev": 0 }); +var UR = parseInt(ChatMsg.unread); +if (UR > 20) { + if (UR > 200) + UR = 200; + ChatMsg = API.messages.getHistory({ "peer_id": PeerId, "count": UR, "rev": 0 }); +}; +var FMsgs = ChatMsg.items@.fwd_messages; +var Idx = 0; +var Uids = []; +var GUids =[]; +while (Idx < FMsgs.length) { + var Jdx = 0; + var CFMsgs = parseInt(FMsgs[Idx].length); + while (Jdx < CFMsgs) { + if (FMsgs[Idx][Jdx].from_id>0) { + Uids.unshift(FMsgs[Idx][Jdx].from_id); + } else { + GUids.unshift(-1*FMsgs[Idx][Jdx].from_id); + }; + Jdx = Jdx + 1; + }; + Idx = Idx + 1; +}; +var FUsers = API.users.get({ "user_ids": Uids, "name_case": "gen" }); +var GUsers = []; +if(GUids.length>0){ + GUsers = API.groups.getById({ "group_ids": GUids }); +}; +var MsgUsers = API.users.get({ "user_ids": ChatMsg.items@.from_id, "fields":"id,first_name,last_name"}); + +return { "info": Info, "users": ChatUsers, "msgs": ChatMsg, "fwd_users": FUsers + GUsers.groups, "msgs_users": MsgUsers}; // Stored procedure name: RetrieveChatInfo = End // Stored procedure name: DestroyKickChat = Begin -- cgit v1.2.3