summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/vk_messages.cpp
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2024-10-22 15:05:57 +0500
committerElzorFox <elzorfox@ya.ru>2024-10-22 15:05:57 +0500
commit2bdb710cd949cc04b294f5de54d17af5d7fd05a7 (patch)
treed51d5aed6050c1c29f5fab320b0d3be9f3a507a7 /protocols/VKontakte/src/vk_messages.cpp
parent086a4572ba5c41ee8231d8c1a13288b42a4886c1 (diff)
VKontakte:
fix send forward and reply messages version bump
Diffstat (limited to 'protocols/VKontakte/src/vk_messages.cpp')
-rw-r--r--protocols/VKontakte/src/vk_messages.cpp36
1 files changed, 29 insertions, 7 deletions
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp
index 6190be65a4..4a93a0859b 100644
--- a/protocols/VKontakte/src/vk_messages.cpp
+++ b/protocols/VKontakte/src/vk_messages.cpp
@@ -47,6 +47,8 @@ int CVkProto::ForwardMsg(MCONTACT hContact, std::vector<MEVENT>& vForvardEvents,
CMStringW wszForwardMessagesTxt;
int iForwardVKMessageCount = 0;
+ MCONTACT hFromContact = INVALID_CONTACT_ID;
+
for (auto &mEvnt : vForvardEvents) {
if (iForwardVKMessageCount == VK_MAX_FORWARD_MESSAGES)
break;
@@ -80,6 +82,7 @@ int CVkProto::ForwardMsg(MCONTACT hContact, std::vector<MEVENT>& vForvardEvents,
if (!szIds.IsEmpty())
szIds.AppendChar(',');
szIds += dbei.szId;
+ hFromContact = dbei.hContact;
}
}
@@ -92,11 +95,21 @@ int CVkProto::ForwardMsg(MCONTACT hContact, std::vector<MEVENT>& vForvardEvents,
&CVkProto::OnSendMessage,
AsyncHttpRequest::rpHigh
);
-
- pReq
- << INT_PARAM(bIsChat ? "chat_id" : "peer_id", iUserId)
- << INT_PARAM("random_id", ((long)time(0)) * 100 + uMsgId % 100)
- << CHAR_PARAM("forward_messages", szIds);
+
+ CMStringA szForward;
+ if (hFromContact != INVALID_CONTACT_ID) {
+ szForward.AppendFormat(
+ "{\"peer_id\":%d, \"message_ids\":[%s]}",
+ isChatRoom(hFromContact) ? (ReadVKUserID(hFromContact) + VK_CHAT_MIN) : ReadVKUserID(hFromContact) ,
+ szIds.c_str()
+ );
+
+ pReq << CHAR_PARAM("forward", szForward);
+ }
+
+ pReq
+ << INT_PARAM(bIsChat ? "chat_id" : "peer_id", iUserId)
+ << INT_PARAM("random_id", ((long)time(0)) * 100 + uMsgId % 100);
pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");
@@ -167,8 +180,17 @@ int CVkProto::SendMsg(MCONTACT hContact, MEVENT hReplyEvent, const char *szMsg)
if (hReplyEvent) {
DB::EventInfo dbei(hReplyEvent, false);
- if (dbei && mir_strlen(dbei.szId) > 0)
- pReq << CHAR_PARAM("reply_to", dbei.szId);
+ if (dbei && mir_strlen(dbei.szId) > 0) {
+ MCONTACT hFromContact = dbei.hContact;
+ CMStringA szForward(
+ FORMAT,
+ "{\"peer_id\":%d, \"message_ids\":[%s], \"is_reply\":1}",
+ isChatRoom(hFromContact) ? (ReadVKUserID(hFromContact) + VK_CHAT_MIN) : ReadVKUserID(hFromContact),
+ dbei.szId
+ );
+
+ pReq << CHAR_PARAM("forward", szForward);
+ }
}
if (StickerId)