summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/vk_files.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/VKontakte/src/vk_files.cpp')
-rw-r--r--protocols/VKontakte/src/vk_files.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp
index 59c2e75c6e..6730e4657a 100644
--- a/protocols/VKontakte/src/vk_files.cpp
+++ b/protocols/VKontakte/src/vk_files.cpp
@@ -321,12 +321,31 @@ void CVkProto::OnReciveUploadFile(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR
return;
}
+#if (VK_NEW_API == 1)
+ int id, owner_id;
+ if (fup->GetType() == CVkFileUploadParam::typeDoc) {
+ CMStringA wszType(jnResponse["type"].as_mstring());
+ const JSONNode& jnDoc = jnResponse[wszType];
+ id = jnDoc["id"].as_int();
+ owner_id = jnDoc["owner_id"].as_int();
+ }
+ else {
+ id = fup->GetType() == CVkFileUploadParam::typeAudio ? jnResponse["id"].as_int() : (*jnResponse.begin())["id"].as_int();
+ owner_id = fup->GetType() == CVkFileUploadParam::typeAudio ? jnResponse["owner_id"].as_int() : (*jnResponse.begin())["owner_id"].as_int();
+ }
+
+ if ((id == 0) || (owner_id == 0)) {
+ SendFileFiled(fup, VKERR_INVALID_PARAMETERS);
+ return;
+ }
+#else
int id = fup->GetType() == CVkFileUploadParam::typeAudio ? jnResponse["id"].as_int() : (*jnResponse.begin())["id"].as_int();
int owner_id = fup->GetType() == CVkFileUploadParam::typeAudio ? jnResponse["owner_id"].as_int() : (*jnResponse.begin())["owner_id"].as_int();
if ((id == 0) || (owner_id == 0)) {
SendFileFiled(fup, VKERR_INVALID_PARAMETERS);
return;
}
+#endif
CMStringW Attachment;
@@ -377,10 +396,11 @@ 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", userID);
pMsgReq->pUserInfo = new CVkSendMsgParam(fup->hContact, fup);
-
}
+ ULONG uMsgId = ::InterlockedIncrement(&m_msgId);
pMsgReq << WCHAR_PARAM("message", fup->Desc) << WCHAR_PARAM("attachment", Attachment);
+ pMsgReq << INT_PARAM("random_id", ((LONG)time(0)) * 100 + uMsgId % 100);
pMsgReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");
Push(pMsgReq);