diff options
author | ElzorFox <elzorfox@ya.ru> | 2024-04-01 15:27:24 +0500 |
---|---|---|
committer | ElzorFox <elzorfox@ya.ru> | 2024-04-01 15:27:24 +0500 |
commit | d4ab2e7d0147a5443b5fbf03dedc3324f0b1b2cf (patch) | |
tree | 59abe93b92745f8a5f269f3a506a1e056c203ee9 /protocols | |
parent | 29d669dd1abca08c6fb72a1b837bc4e3665e7d33 (diff) |
VKontakte:
fix #4308
add full support for sync muc history
version bump
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 3 | ||||
-rw-r--r-- | protocols/VKontakte/src/version.h | 4 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_chats.cpp | 5 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_history.cpp | 27 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_messages.cpp | 23 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 4 | ||||
-rw-r--r-- | protocols/VKontakte/src/vkjs.js | 14 |
7 files changed, 53 insertions, 27 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index bf278341b0..fb8127a1b6 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -867,8 +867,7 @@ int CVkProto::OnProcessSrmmEvent(WPARAM uType, LPARAM lParam) if (uType == MSG_WINDOW_EVT_OPENING && !g_bMessageState)
SetSrmmReadStatus(pDlg->m_hContact);
- if (uType == MSG_WINDOW_EVT_OPENING && m_vkOptions.bLoadLastMessageOnMsgWindowsOpen
- && !isChatRoom(pDlg->m_hContact) && IsHystoryMessageExist(pDlg->m_hContact) != 1) {
+ if (uType == MSG_WINDOW_EVT_OPENING && m_vkOptions.bLoadLastMessageOnMsgWindowsOpen && IsHystoryMessageExist(pDlg->m_hContact) != 1) {
m_bNotifyForEndLoadingHistory = false;
if (!getBool(pDlg->m_hContact, "ActiveHistoryTask")) {
setByte(pDlg->m_hContact, "ActiveHistoryTask", 1);
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h index 76ae65be88..80177e2652 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 8
+#define __RELEASE_NUM 16
+#define __BUILD_NUM 0
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 666e2fc57b..fc8cade822 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 : 4)
+ << INT_PARAM("func_v", (cc->m_bHistoryRead || m_vkOptions.iSyncHistoryMetod) ? 5 : 4)
)->pUserInfo = cc;
}
@@ -406,9 +406,10 @@ void CVkProto::AppendChatConversationMessage(VKUserID_t iChatId, const JSONNode& wszBody += wszAttachmentDescr;
}
- if (m_vkOptions.bAddMessageLinkToMesWAtt && ((jnAttachments && !jnAttachments.empty()) || (jnFwdMessages && !jnFwdMessages.empty()) || (jnReplyMessages && !jnReplyMessages.empty())))
+ if (m_vkOptions.bAddMessageLinkToMesWAtt && ((jnAttachments && !jnAttachments.empty()) || (jnFwdMessages && !jnFwdMessages.empty()) || (jnReplyMessages && !jnReplyMessages.empty() && m_vkOptions.bShowReplyInMessage)))
wszBody += SetBBCString(TranslateT("Message link"), bbcNo, vkbbcUrl,
CMStringW(FORMAT, L"https://vk.com/im?sel=c%d&msgid=%d", vkChatInfo->m_iChatId, iMessageId));
+
if (jnMsg["action"] && jnMsg["action"]["type"]) {
bIsAction = true;
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index 2c228a27e0..7504b846e8 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -125,7 +125,8 @@ void CVkProto::GetServerHistory(MCONTACT hContact, int iOffset, int iCount, time if (!IsOnline() || iCount == 0)
return;
- VKUserID_t iUserId = ReadVKUserID(hContact);
+ VKUserID_t iUserId = isChatRoom(hContact) ? VK_CHAT_MIN + ReadVKUserID(hContact) : ReadVKUserID(hContact);
+
debugLogA("CVkProto::GetServerHistory %ld %d %d %d %d %d", iUserId, iOffset, iCount, tTime, iLastMsgId, (int)bOnce);
if (VK_INVALID_USER == iUserId || iUserId == VK_FEED_USER)
return;
@@ -225,15 +226,27 @@ void CVkProto::OnReceiveHistoryMessages(MHttpResponse *reply, AsyncHttpRequest * if (iLastMsgId < iMessageId)
iLastMsgId = iMessageId;
- char szMid[40], szReplyId[40] = "";
- _ltoa(iMessageId, szMid, 10);
-
- CMStringW wszBody(jnMsg["text"].as_mstring());
VKUserID_t iUserId = jnMsg["peer_id"].as_int();
+ VKUserID_t iChatId = (GetVKPeerType(iUserId) == VKPeerType::vkPeerMUC) ? iUserId % VK_CHAT_MIN : 0;
VKMessageID_t iReadMsg = ReadQSWord(param->hContact, "in_read", 0);
bool bIsRead = (iMessageId <= iReadMsg);
- time_t tDateTime = jnMsg["date"].as_int();
bool bIsOut = jnMsg["out"].as_int();
+ time_t tDateTime = jnMsg["date"].as_int();
+
+ if (iChatId != 0){
+ AppendChatConversationMessage(iChatId, jnMsg, jnFUsers, true);
+
+ if (bIsRead && bIsOut && tDateTime > tLastReadMessageTime)
+ tLastReadMessageTime = tDateTime;
+
+ count++;
+ continue;
+ }
+
+ char szMid[40], szReplyId[40] = "";
+ _ltoa(iMessageId, szMid, 10);
+
+ CMStringW wszBody(jnMsg["text"].as_mstring());
MCONTACT hContact = FindUser(iUserId, true);
const JSONNode &jnFwdMessages = jnMsg["fwd_messages"];
@@ -269,7 +282,7 @@ void CVkProto::OnReceiveHistoryMessages(MHttpResponse *reply, AsyncHttpRequest * wszBody += wszAttachmentDescr;
}
- if (m_vkOptions.bAddMessageLinkToMesWAtt && ((jnAttachments && !jnAttachments.empty()) || (jnFwdMessages && !jnFwdMessages.empty()) || (jnReplyMessages && !jnReplyMessages.empty())))
+ if (m_vkOptions.bAddMessageLinkToMesWAtt && ((jnAttachments && !jnAttachments.empty()) || (jnFwdMessages && !jnFwdMessages.empty()) || (jnReplyMessages && !jnReplyMessages.empty() && m_vkOptions.bShowReplyInMessage)))
wszBody += SetBBCString(TranslateT("Message link"), m_vkOptions.BBCForAttachments(), vkbbcUrl,
CMStringW(FORMAT, L"https://vk.com/im?sel=%d&msgid=%d", iUserId, iMessageId));
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index 93850eea06..6cb7180ec1 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -413,7 +413,7 @@ void CVkProto::OnReceiveMessages(MHttpResponse *reply, AsyncHttpRequest *pReq) wszBody += wszAttachmentDescr;
}
- if (m_vkOptions.bAddMessageLinkToMesWAtt && ((jnAttachments && !jnAttachments.empty()) || (jnFwdMessages && !jnFwdMessages.empty()) || (jnReplyMessages && !jnReplyMessages.empty())))
+ if (m_vkOptions.bAddMessageLinkToMesWAtt && ((jnAttachments && !jnAttachments.empty()) || (jnFwdMessages && !jnFwdMessages.empty()) || (jnReplyMessages && !jnReplyMessages.empty() && m_vkOptions.bShowReplyInMessage)))
wszBody += SetBBCString(TranslateT("Message link"), m_vkOptions.BBCForAttachments(), vkbbcUrl,
CMStringW(FORMAT, L"https://vk.com/im?sel=%d&msgid=%d", iUserId, iMessageId));
@@ -573,13 +573,6 @@ void CVkProto::OnReceiveDlgs(MHttpResponse *reply, AsyncHttpRequest *pReq) WriteQSWord(hContact, "in_read", jnConversation["in_read"].as_int());
WriteQSWord(hContact, "out_read", jnConversation["out_read"].as_int());
- if (g_bMessageState) {
- bool bIsOut = jnLastMessage["out"].as_bool();
- bool bIsRead = (jnLastMessage["id"].as_int() <= jnConversation["in_read"].as_int());
-
- if (bIsRead && bIsOut)
- CallService(MS_MESSAGESTATE_UPDATE, hContact, MRD_TYPE_DELIVERED);
- }
}
if (wszPeerType == L"chat") {
@@ -587,8 +580,20 @@ void CVkProto::OnReceiveDlgs(MHttpResponse *reply, AsyncHttpRequest *pReq) debugLogA("CVkProto::OnReceiveDlgs chatid = %d", iChatId);
if (m_chats.find((CVkChatInfo*)&iChatId) == nullptr)
AppendConversationChat(iChatId, it);
+
+ hContact = FindChat(iChatId);
+ }
+
+ if (g_bMessageState) {
+ bool bIsOut = jnLastMessage["out"].as_bool();
+ bool bIsRead = (jnLastMessage["id"].as_int() <= jnConversation["in_read"].as_int());
+
+ if (bIsRead && bIsOut)
+ CallService(MS_MESSAGESTATE_UPDATE, hContact, MRD_TYPE_DELIVERED);
}
- else if (m_vkOptions.iSyncHistoryMetod) {
+
+
+ if (m_vkOptions.iSyncHistoryMetod) {
VKMessageID_t iMessageId = jnLastMessage["id"].as_int();
m_bNotifyForEndLoadingHistory = false;
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index 8bd1c362c4..b1559c40ae 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -408,10 +408,10 @@ int CVkProto::OnPreBuildContactMenu(WPARAM hContact, LPARAM) Menu_ShowItem(m_hContactMenuItems[CMI_CHATINVITEUSER], isChatRoom(hContact));
Menu_ShowItem(m_hContactMenuItems[CMI_CHATDESTROY], isChatRoom(hContact));
- Menu_ShowItem(m_hContactMenuItems[CMI_GETSERVERHISTORY], !isChatRoom(hContact) && iUserId != VK_FEED_USER);
+ Menu_ShowItem(m_hContactMenuItems[CMI_GETSERVERHISTORY], iUserId != VK_FEED_USER);
Menu_ShowItem(m_hContactMenuItems[CMI_LOADVKNEWS], iUserId == VK_FEED_USER);
for (int i = 0; i < CHMI_COUNT; i++)
- Menu_ShowItem(m_hContactHistoryMenuItems[i], !isChatRoom(hContact) && iUserId != VK_FEED_USER);
+ Menu_ShowItem(m_hContactHistoryMenuItems[i], iUserId != VK_FEED_USER);
return 0;
}
diff --git a/protocols/VKontakte/src/vkjs.js b/protocols/VKontakte/src/vkjs.js index a5b0485c8f..59a57a0677 100644 --- a/protocols/VKontakte/src/vkjs.js +++ b/protocols/VKontakte/src/vkjs.js @@ -302,9 +302,9 @@ return 1; // Args.chatid // ver 1 -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;}; +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 2 @@ -409,6 +409,14 @@ if(GUids.length>0){ 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}; + + +// ver 5 +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" }); +return {"info":Info,"users":ChatUsers}; + // Stored procedure name: RetrieveChatInfo = End // Stored procedure name: DestroyKickChat = Begin |