diff options
author | George Hazan <george.hazan@gmail.com> | 2024-01-10 20:11:38 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-01-10 20:11:38 +0300 |
commit | 04b8a61c89ef27e03ce3d9057bb98998c769a8a3 (patch) | |
tree | d558f818f388d690de7d1a62a56d2f02207fc8fc /protocols/ICQ-WIM | |
parent | 730c132f369842cd219388905cf981c2e90f98b3 (diff) |
fixes #4107 (ICQ: очередное неопределение оффлайн файла в ответе картинкой)
Diffstat (limited to 'protocols/ICQ-WIM')
-rw-r--r-- | protocols/ICQ-WIM/src/proto.h | 1 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/server.cpp | 69 |
2 files changed, 50 insertions, 20 deletions
diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index dfb75d78a3..7de752df5b 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -243,6 +243,7 @@ class CIcqProto : public PROTO<CIcqProto> void Json2string(MCONTACT, const JSONNode&, const char *szJson, const char *szSetting, bool bIsPartial);
MCONTACT ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact = INVALID_CONTACT_ID, bool bIsPartial = false);
void ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNode &msg, bool bCreateRead, bool bLocalTime);
+ void ParseMessagePart(MCONTACT hContact, const JSONNode &msg, MEVENT hOldEvent, IcqFileInfo *&pFileInfo);
IcqFileInfo* RetrieveFileInfo(MCONTACT hContact, const CMStringW &wszUrl);
int StatusFromPresence(const JSONNode &presence, MCONTACT hContact);
void ProcessPatchVersion(MCONTACT hContact, __int64 currPatch);
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index 67361d82b7..ba6a41728b 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -451,7 +451,7 @@ MCONTACT CIcqProto::ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact, boo void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNode &it, bool bCreateRead, bool bLocalTime)
{
- CMStringA szMsgId(it["msgId"].as_mstring()), szSender;
+ CMStringA szMsgId(it["msgId"].as_mstring()), szSender, szReply;
__int64 msgId = _atoi64(szMsgId);
if (msgId > lastMsgId)
lastMsgId = msgId;
@@ -533,33 +533,33 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo // check for embedded file
IcqFileInfo *pFileInfo = nullptr;
+ const JSONNode *pForward = nullptr, *pQuote = nullptr;
for (auto &jt : it["parts"]) {
- if (auto &content = jt["captionedContent"]) {
- CMStringW wszUrl(content["url"].as_mstring());
- if (wszUrl.IsEmpty())
- continue;
-
- if (hOldEvent && fileText2url(wszText))
- return;
+ auto szType = jt["mediaType"].as_string();
+ if (szType == "forward")
+ pForward = &jt;
+ else if (szType == "quote")
+ pQuote = &jt;
+ else if (szType == "text")
+ ParseMessagePart(hContact, jt, hOldEvent, pFileInfo);
+ }
- if (!CheckFile(hContact, wszUrl, pFileInfo))
- continue;
+ if (pForward) {
+ int idx = wszText.Find(L"\n\n");
+ if (idx != -1)
+ wszText.Truncate(idx + 2);
- if (jt["mediaType"].as_string() == "forward") {
- int idx = wszText.Find(L"\n\n");
- if (idx != -1)
- wszText.Truncate(idx + 2);
+ if (!pFileInfo) {
+ ParseMessagePart(hContact, *pForward, hOldEvent, pFileInfo);
+ if (pFileInfo)
pFileInfo->wszDescr = wszText;
- }
-
- CMStringW wszDescr(content["caption"].as_mstring());
- if (!wszDescr.IsEmpty())
- pFileInfo->wszDescr = wszDescr;
- break;
}
}
+ if (pQuote)
+ szReply = pQuote->at("msgId").as_mstring();
+
// message text might be a separate file link as well
if (pFileInfo == nullptr && fileText2url(wszText)) {
if (hOldEvent)
@@ -602,6 +602,8 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo pre.dwFlags |= PRFF_READ;
if (bIsOutgoing)
pre.dwFlags |= PRFF_SENT;
+ if (!szReply.IsEmpty())
+ pre.szReplyId = szReply;
if (isChatRoom(hContact))
pre.szUserId = szSender;
ProtoChainRecvFile(hContact, &pre);
@@ -633,6 +635,8 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo dbei.szId = szMsgId;
if (isChatRoom(hContact))
dbei.szUserId = szSender;
+ if (!szReply.IsEmpty())
+ dbei.szReplyId = szReply;
db_event_edit(hOldEvent, &dbei, true);
}
else {
@@ -646,10 +650,35 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo pre.szMsgId = szMsgId;
if (isChatRoom(hContact))
pre.szUserId = szSender;
+ if (!szReply.IsEmpty())
+ pre.szReplyId = szReply;
ProtoChainRecvMsg(hContact, &pre);
}
}
+void CIcqProto::ParseMessagePart(MCONTACT hContact, const JSONNode &part, MEVENT hOldEvent, IcqFileInfo *&pFileInfo)
+{
+ if (pFileInfo != nullptr)
+ return;
+
+ if (auto &content = part["captionedContent"]) {
+ CMStringW wszUrl(content["url"].as_mstring());
+ if (wszUrl.IsEmpty())
+ return;
+
+ CMStringW wszText(part["text"].as_mstring());
+ if (hOldEvent && fileText2url(wszText))
+ return;
+
+ if (!CheckFile(hContact, wszUrl, pFileInfo))
+ return;
+
+ CMStringW wszDescr(content["caption"].as_mstring());
+ if (!wszDescr.IsEmpty())
+ pFileInfo->wszDescr = wszDescr;
+ }
+}
+
bool CIcqProto::RefreshRobustToken(AsyncHttpRequest *pOrigReq)
{
if (!m_szRToken.IsEmpty())
|