summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/vk_history.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/VKontakte/src/vk_history.cpp')
-rw-r--r--protocols/VKontakte/src/vk_history.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp
index 3e7a05a8e7..7695e33859 100644
--- a/protocols/VKontakte/src/vk_history.cpp
+++ b/protocols/VKontakte/src/vk_history.cpp
@@ -130,6 +130,7 @@ void CVkProto::GetServerHistory(MCONTACT hContact, int iOffset, int iCount, int
if (VK_INVALID_USER == userID || userID == VK_FEED_USER)
return;
+#if (VK_NEW_API == 0)
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.GetServerHistory", true, &CVkProto::OnReceiveHistoryMessages, AsyncHttpRequest::rpLow)
<< INT_PARAM("reqcount", iCount)
<< INT_PARAM("offset", iOffset)
@@ -138,7 +139,16 @@ void CVkProto::GetServerHistory(MCONTACT hContact, int iOffset, int iCount, int
<< INT_PARAM("lastmid", iLastMsgId)
<< INT_PARAM("once", (int)once)
)->pUserInfo = new CVkSendMsgParam(hContact, iLastMsgId, iOffset);
-
+#else
+ Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/execute.GetServerConversationHistory", true, &CVkProto::OnReceiveHistoryMessages, AsyncHttpRequest::rpLow)
+ << INT_PARAM("reqcount", iCount)
+ << INT_PARAM("offset", iOffset)
+ << INT_PARAM("userid", userID)
+ << INT_PARAM("time", iTime)
+ << INT_PARAM("lastmid", iLastMsgId)
+ << INT_PARAM("once", (int)once)
+ )->pUserInfo = new CVkSendMsgParam(hContact, iLastMsgId, iOffset);
+#endif
}
void CVkProto::GetHistoryDlg(MCONTACT hContact, int iLastMsg)
@@ -224,21 +234,31 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
for (auto it = jnMsgs.rbegin(); it != jnMsgs.rend(); ++it) {
const JSONNode &jnMsg = (*it);
+#if (VK_NEW_API == 1)
+ int mid = jnMsg["conversation_message_id"].as_int();
+#else
int mid = jnMsg["id"].as_int();
+#endif
+
if (iLastMsgId < mid)
iLastMsgId = mid;
char szMid[40];
_itoa(mid, szMid, 10);
-
+#if (VK_NEW_API == 1)
+ CMStringW wszBody(jnMsg["text"].as_mstring());
+ int uid = jnMsg["peer_id"].as_int();
+#else
CMStringW wszBody(jnMsg["body"].as_mstring());
+ int uid = jnMsg["user_id"].as_int();
+#endif
+
int datetime = jnMsg["date"].as_int();
int isOut = jnMsg["out"].as_int();
int isRead = jnMsg["read_state"].as_int();
- int uid = jnMsg["user_id"].as_int();
const JSONNode &jnFwdMessages = jnMsg["fwd_messages"];
- if (jnFwdMessages) {
+ if (jnFwdMessages && !jnFwdMessages.empty()) {
CMStringW wszFwdMessages = GetFwdMessages(jnFwdMessages, jnFUsers, m_vkOptions.BBCForAttachments());
if (!wszBody.IsEmpty())
wszFwdMessages = L"\n" + wszFwdMessages;
@@ -246,7 +266,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque
}
const JSONNode &jnAttachments = jnMsg["attachments"];
- if (jnAttachments) {
+ if (jnAttachments && !jnAttachments.empty()) {
CMStringW wszAttachmentDescr = GetAttachmentDescr(jnAttachments, m_vkOptions.BBCForAttachments());
if (wszAttachmentDescr == L"== FilterAudioMessages ==") {