From 57fb5a039ebb74fd276d7bd0224406f29f9d18b9 Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Tue, 8 Sep 2015 04:22:07 +0000 Subject: VKontakte: PF4_GROUPCHATFILES support version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@15304 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/vk_files.cpp | 46 +++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 11 deletions(-) (limited to 'protocols/VKontakte/src/vk_files.cpp') diff --git a/protocols/VKontakte/src/vk_files.cpp b/protocols/VKontakte/src/vk_files.cpp index 932841f050..2423899ddb 100644 --- a/protocols/VKontakte/src/vk_files.cpp +++ b/protocols/VKontakte/src/vk_files.cpp @@ -20,8 +20,9 @@ along with this program. If not, see . HANDLE CVkProto::SendFile(MCONTACT hContact, const TCHAR *desc, TCHAR **files) { debugLogA("CVkProto::SendFile"); + isChatRoom(hContact); LONG userID = getDword(hContact, "ID", -1); - if (!IsOnline() || userID == -1 || userID == VK_FEED_USER) + if (!IsOnline() || ((userID == -1 || userID == VK_FEED_USER) && !isChatRoom(hContact))) return (HANDLE)0; CVkFileUploadParam *fup = new CVkFileUploadParam(hContact, desc, files); @@ -352,20 +353,43 @@ void CVkProto::OnReciveUploadFile(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pR SendFileFiled(fup, VKERR_FTYPE_NOT_SUPPORTED); return; } + + AsyncHttpRequest *pMsgReq; - LONG userID = getDword(fup->hContact, "ID", -1); - if (userID == -1 || userID == VK_FEED_USER) { - SendFileFiled(fup, VKERR_INVALID_USER); - return; + if (isChatRoom(fup->hContact)) { + + ptrT tszChatID(getTStringA(fup->hContact, "ChatRoomID")); + if (!tszChatID) { + SendFileFiled(fup, VKERR_INVALID_USER); + return; + } + + CVkChatInfo *cc = GetChatById(tszChatID); + if (cc == NULL) { + SendFileFiled(fup, VKERR_INVALID_USER); + return; + } + + pMsgReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendChatMsg, AsyncHttpRequest::rpHigh) + << INT_PARAM("chat_id", cc->m_chatid); + pMsgReq->pUserInfo = pReq->pUserInfo; + + } + else { + LONG userID = getDword(fup->hContact, "ID", -1); + if (userID == -1 || userID == VK_FEED_USER) { + SendFileFiled(fup, VKERR_INVALID_USER); + return; + } + + pMsgReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh) + << INT_PARAM("user_id", userID); + pMsgReq->pUserInfo = new CVkSendMsgParam(fup->hContact, fup); + } - AsyncHttpRequest *pMsgReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh) - << INT_PARAM("user_id", userID) - << TCHAR_PARAM("message", fup->Desc) - << TCHAR_PARAM("attachment", Attachment) - << VER_API; + pMsgReq << TCHAR_PARAM("message", fup->Desc) << TCHAR_PARAM("attachment", Attachment) << VER_API; pMsgReq->AddHeader("Content-Type", "application/x-www-form-urlencoded"); - pMsgReq->pUserInfo = new CVkSendMsgParam(fup->hContact, fup); Push(pMsgReq); } \ No newline at end of file -- cgit v1.2.3