summaryrefslogtreecommitdiff
path: root/protocols/VKontakte
diff options
context:
space:
mode:
authorElzorFox <elzorfox@ya.ru>2024-03-31 18:10:27 +0500
committerElzorFox <elzorfox@ya.ru>2024-03-31 18:10:44 +0500
commite23adc4331ca6600b775b28dec9725f28998a5ee (patch)
tree5d0121f5f1a41ae2e16c1267589306ffd7fa3f9f /protocols/VKontakte
parentb8f2e677b094dfe4e09f7971ef01316f6b3c21a7 (diff)
VKontakte:
fix # 4307 fix # 4309 add NewStory-style for reply from groupchats version bump
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r--protocols/VKontakte/src/misc.cpp14
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp65
-rw-r--r--protocols/VKontakte/src/vk_proto.h3
-rw-r--r--protocols/VKontakte/src/vk_struct.h2
5 files changed, 54 insertions, 32 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 8795f4d6d1..bf278341b0 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -254,7 +254,21 @@ void CVkProto::SetAllContactStatuses(int iStatus)
}
/////////////////////////////////////////////////////////////////////////////////////////
+MCONTACT CVkProto::FindTempUser(VKUserID_t iUserId, int iWait)
+{
+ MCONTACT hContact = FindUser(iUserId);
+ if (hContact == 0) {
+ hContact = FindUser(iUserId, true);
+ RetrieveUserInfo(iUserId);
+ Contact::Hide(hContact);
+ Contact::RemoveFromList(hContact);
+ db_set_dw(hContact, "Ignore", "Mask1", 0);
+ if (iWait)
+ Sleep(iWait);
+ }
+ return hContact;
+}
MCONTACT CVkProto::FindUser(VKUserID_t dwUserid, bool bCreate)
{
if (!dwUserid)
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index 82f9b04cc0..76ae65be88 100644
--- a/protocols/VKontakte/src/version.h
+++ b/protocols/VKontakte/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 15
-#define __BUILD_NUM 7
+#define __BUILD_NUM 8
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index 34e4693848..666e2fc57b 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -334,7 +334,7 @@ void CVkProto::OnReceiveChatInfo(MHttpResponse *reply, AsyncHttpRequest *pReq)
cc->m_bHistoryRead = true;
for (auto &p : cc->m_msgs)
- AppendChatMessage(cc, p->m_iMessageId, p->m_iUserId, p->m_tDate, p->m_wszBody, p->m_bHistory, p->m_bIsAction);
+ AppendChatMessage(cc, p->m_iMessageId, p->m_iReplyMsgId, p->m_iUserId, p->m_tDate, p->m_wszBody, p->m_bHistory, p->m_bIsAction);
cc->m_msgs.destroy();
}
@@ -363,7 +363,7 @@ void CVkProto::AppendChatConversationMessage(VKUserID_t iChatId, const JSONNode&
if (vkChatInfo == nullptr)
return;
- VKMessageID_t iMessageId = jnMsg["id"].as_int();
+ VKMessageID_t iMessageId = jnMsg["id"].as_int(), iReplyMsgId = 0;
VKUserID_t iUserId = jnMsg["from_id"].as_int();
bool bIsAction = false;
@@ -384,10 +384,14 @@ void CVkProto::AppendChatConversationMessage(VKUserID_t iChatId, const JSONNode&
const JSONNode& jnReplyMessages = jnMsg["reply_message"];
if (jnReplyMessages && !jnReplyMessages.empty()) {
- CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, bbcNo);
- if (!wszBody.IsEmpty())
- wszReplyMessages = L"\n" + wszReplyMessages;
- wszBody += wszReplyMessages;
+ if (m_vkOptions.bShowReplyInMessage) {
+ CMStringW wszReplyMessages = GetFwdMessages(jnReplyMessages, jnFUsers, bbcNo);
+ if (!wszBody.IsEmpty())
+ wszReplyMessages = L"\n" + wszReplyMessages;
+ wszBody += wszReplyMessages;
+ }
+ else if (jnReplyMessages["id"])
+ iReplyMsgId = jnReplyMessages["id"].as_int();
}
const JSONNode& jnAttachments = jnMsg["attachments"];
@@ -483,13 +487,14 @@ void CVkProto::AppendChatConversationMessage(VKUserID_t iChatId, const JSONNode&
wszBody.Replace(L"%", L"%%");
if (vkChatInfo->m_bHistoryRead) {
- AppendChatMessage(vkChatInfo, iMessageId, iUserId, tMsgTime, wszBody, bIsHistory, bIsAction);
+ AppendChatMessage(vkChatInfo, iMessageId, iReplyMsgId, iUserId, tMsgTime, wszBody, bIsHistory, bIsAction);
}
else {
CVkChatMessage* vkChatMessage = vkChatInfo->m_msgs.find((CVkChatMessage*)&iMessageId);
if (vkChatMessage == nullptr)
vkChatInfo->m_msgs.insert(vkChatMessage = new CVkChatMessage(iMessageId));
-
+
+ vkChatMessage->m_iReplyMsgId = iReplyMsgId;
vkChatMessage->m_iUserId = iUserId;
vkChatMessage->m_tDate = tMsgTime;
vkChatMessage->m_wszBody = mir_wstrdup(wszBody);
@@ -499,7 +504,7 @@ void CVkProto::AppendChatConversationMessage(VKUserID_t iChatId, const JSONNode&
}
-void CVkProto::AppendChatMessage(CVkChatInfo* vkChatInfo, VKMessageID_t iMessageId, VKUserID_t iUserId, time_t tMsgTime, LPCWSTR pwszBody, bool bIsHistory, bool bIsAction)
+void CVkProto::AppendChatMessage(CVkChatInfo* vkChatInfo, VKMessageID_t iMessageId, VKMessageID_t iReplyMsgId, VKUserID_t iUserId, time_t tMsgTime, LPCWSTR pwszBody, bool bIsHistory, bool bIsAction)
{
debugLogA("CVkProto::AppendChatMessage2");
@@ -507,16 +512,17 @@ void CVkProto::AppendChatMessage(CVkChatInfo* vkChatInfo, VKMessageID_t iMessage
if (!hChatContact)
return;
- if (bIsAction) {
- MCONTACT hContact = FindUser(iUserId);
- CVkChatUser* cu = vkChatInfo->m_users.find((CVkChatUser*)&iUserId);
- if (cu == nullptr) {
- vkChatInfo->m_users.insert(cu = new CVkChatUser(iUserId));
- CMStringW wszNick(ptrW(db_get_wsa(vkChatInfo->m_si->hContact, m_szModuleName, CMStringA(FORMAT, "nick%d", cu->m_iUserId))));
- cu->m_wszNick = mir_wstrdup(wszNick.IsEmpty() ? (hContact ? ptrW(db_get_wsa(hContact, m_szModuleName, "Nick")) : TranslateT("Unknown")) : wszNick);
- cu->m_bUnknown = true;
- }
+ MCONTACT hContact = FindTempUser(iUserId);
+
+ CVkChatUser* cu = vkChatInfo->m_users.find((CVkChatUser*)&iUserId);
+ if (cu == nullptr) {
+ vkChatInfo->m_users.insert(cu = new CVkChatUser(iUserId));
+ CMStringW wszNick(ptrW(db_get_wsa(vkChatInfo->m_si->hContact, m_szModuleName, CMStringA(FORMAT, "nick%d", cu->m_iUserId))));
+ cu->m_wszNick = mir_wstrdup(wszNick.IsEmpty() ? (hContact ? ptrW(db_get_wsa(hContact, m_szModuleName, "Nick")) : TranslateT("Unknown")) : wszNick);
+ cu->m_bUnknown = true;
+ }
+ if (bIsAction) {
wchar_t wszId[20];
_itow(iUserId, wszId, 10);
@@ -530,14 +536,13 @@ void CVkProto::AppendChatMessage(CVkChatInfo* vkChatInfo, VKMessageID_t iMessage
Chat_Event(&gce);
}
else {
-
- char szId[20];
- _ltoa(iUserId, szId, 10);
-
+ char szReplyMsgId[40] = "";
char szMid[40];
+
_ltoa(iMessageId, szMid, 10);
T2Utf pszBody(pwszBody);
+ T2Utf pszNick(cu->m_wszNick);
DB::EventInfo dbei;
dbei.szId = szMid;
@@ -547,7 +552,13 @@ void CVkProto::AppendChatMessage(CVkChatInfo* vkChatInfo, VKMessageID_t iMessage
dbei.flags |= DBEF_SENT;
if (bIsHistory)
dbei.flags |= DBEF_READ;
- dbei.szUserId = szId;
+ dbei.szUserId = pszNick;
+
+ if (iReplyMsgId) {
+ _ltoa(iReplyMsgId, szReplyMsgId, 10);
+ dbei.szReplyId = szReplyMsgId;
+ }
+
ProtoChainRecvMsg(hChatContact, dbei);
}
@@ -818,13 +829,7 @@ void CVkProto::NickMenuHook(CVkChatInfo *vkChatInfo, GCHOOK *gch)
switch (gch->dwData) {
case IDM_INFO:
- hContact = FindUser(vkChatUser->m_iUserId);
- if (hContact == 0) {
- hContact = FindUser(vkChatUser->m_iUserId, true);
- Contact::Hide(hContact);
- Contact::RemoveFromList(hContact);
- db_set_dw(hContact, "Ignore", "Mask1", 0);
- }
+ hContact = FindTempUser(vkChatUser->m_iUserId, 1000);
CallService(MS_USERINFO_SHOWDIALOG, hContact);
break;
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index ecfec1c4eb..2b05e35bf6 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -358,6 +358,7 @@ private:
//==== Misc ==========================================================================
void SetAllContactStatuses(int iStatus);
+ MCONTACT FindTempUser(VKUserID_t iUserid, int iWait = 0);
MCONTACT FindUser(VKUserID_t iUserId, bool bCreate = false);
MCONTACT FindChat(VKUserID_t iUserId);
JSONNode& CheckJsonResponse(AsyncHttpRequest *pReq, MHttpResponse *reply, JSONNode &root);
@@ -421,7 +422,7 @@ private:
CVkChatInfo* AppendConversationChat(VKUserID_t iChatId, const JSONNode& jnItem);
void SetChatTitle(CVkChatInfo *cc, LPCWSTR wszTopic);
void AppendChatConversationMessage(VKUserID_t iChatId, const JSONNode& jnMsg, const JSONNode& jnFUsers, bool bIsHistory);
- void AppendChatMessage(CVkChatInfo* vkChatInfo, VKMessageID_t iMessageId, VKUserID_t iUserId, time_t tMsgTime, LPCWSTR pwszBody, bool bIsHistory, bool bIsAction = false);
+ void AppendChatMessage(CVkChatInfo* vkChatInfo, VKMessageID_t iMessageId, VKMessageID_t iReplyMsgId, VKUserID_t iUserId, time_t tMsgTime, LPCWSTR pwszBody, bool bIsHistory, bool bIsAction = false);
void RetrieveChatInfo(CVkChatInfo*);
void OnReceiveChatInfo(MHttpResponse*, AsyncHttpRequest*);
void OnSendChatMsg(MHttpResponse*, AsyncHttpRequest*);
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h
index 44642b08e7..33fb96de7f 100644
--- a/protocols/VKontakte/src/vk_struct.h
+++ b/protocols/VKontakte/src/vk_struct.h
@@ -90,6 +90,7 @@ struct CVkChatMessage : public MZeroedObject
{
CVkChatMessage(VKUserID_t _id) :
m_iMessageId(_id),
+ m_iReplyMsgId(0),
m_iUserId(0),
m_tDate(0),
m_bHistory(false),
@@ -97,6 +98,7 @@ struct CVkChatMessage : public MZeroedObject
{}
VKMessageID_t m_iMessageId;
+ VKMessageID_t m_iReplyMsgId;
VKUserID_t m_iUserId;
time_t m_tDate;
bool m_bHistory, m_bIsAction;