diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2015-11-23 05:44:57 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2015-11-23 05:44:57 +0000 |
commit | 1073b96d7e35e4dfb84e5d9d32ab9796f9a863c0 (patch) | |
tree | 4d3d85fff81017dd0a165a4d4a51d8b7c294d9c8 /protocols/VKontakte/src/vk_messages.cpp | |
parent | d5af64fc1ed1bd2f5ccc2a03ec03c19803c00555 (diff) |
VKontakte: use SendMsg for sending to muc
git-svn-id: http://svn.miranda-ng.org/main/trunk@15760 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/vk_messages.cpp')
-rw-r--r-- | protocols/VKontakte/src/vk_messages.cpp | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index cca8ad02d1..aed86581df 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -42,38 +42,43 @@ int CVkProto::SendMsg(MCONTACT hContact, int, const char *szMsg) debugLogA("CVkProto::SendMsg");
if (!IsOnline())
return 0;
- LONG userID = getDword(hContact, "ID", -1);
- if (userID == -1 || userID == VK_FEED_USER) {
+
+ bool bIsChat = isChatRoom(hContact);
+ LONG iUserID = getDword(hContact, bIsChat ? "vk_chat_id" : "ID" , -1);
+
+ if (iUserID == -1 || iUserID == VK_FEED_USER) {
ForkThread(&CVkProto::SendMsgAck, new CVkSendMsgParam(hContact));
return 0;
}
int StickerId = 0;
- ptrA retMsg(GetStickerId(szMsg, StickerId));
+ ptrA pszRetMsg(GetStickerId(szMsg, StickerId));
- ULONG msgId = ::InterlockedIncrement(&m_msgId);
- AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh)
- << INT_PARAM("user_id", userID)
- << INT_PARAM("guid", ((LONG) time(NULL)) * 100 + msgId % 100)
+ ULONG uMsgId = ::InterlockedIncrement(&m_msgId);
+ AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, "/method/messages.send.json", true, bIsChat? &CVkProto::OnSendChatMsg : &CVkProto::OnSendMessage, AsyncHttpRequest::rpHigh)
+ << INT_PARAM(bIsChat ? "chat_id" : "user_id", iUserID)
+ << INT_PARAM("guid", ((LONG) time(NULL)) * 100 + uMsgId % 100)
<< VER_API;
+ pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");
- if (StickerId != 0)
+ if (StickerId)
pReq << INT_PARAM("sticker_id", StickerId);
else
pReq << CHAR_PARAM("message", szMsg);
- pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");
- pReq->pUserInfo = new CVkSendMsgParam(hContact, msgId);
+ if (!bIsChat)
+ pReq->pUserInfo = new CVkSendMsgParam(hContact, uMsgId);
+
Push(pReq);
- if (!m_bServerDelivery)
- ForkThread(&CVkProto::SendMsgAck, new CVkSendMsgParam(hContact, msgId));
+ if (!m_bServerDelivery && !bIsChat)
+ ForkThread(&CVkProto::SendMsgAck, new CVkSendMsgParam(hContact, uMsgId));
- if (!IsEmpty(retMsg)) {
+ if (!IsEmpty(pszRetMsg)) {
Sleep(330);
- SendMsg(hContact, 0, retMsg);
+ SendMsg(hContact, 0, pszRetMsg);
}
- return msgId;
+ return uMsgId;
}
void CVkProto::OnSendMessage(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
|