From 5732a19c7dd15ee2a70fb30b3b27db9514208d2f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 7 Aug 2024 17:19:37 +0300 Subject: =?UTF-8?q?fixes=20#4542=20(SkypeWeb:=20Load=20Server=20History=20?= =?UTF-8?q?=D0=B2=D1=82=D1=8F=D0=B3=D0=B8=D0=B2=D0=B0=D0=B5=D1=82=20=D1=82?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=BD=D0=B5=D0=BA=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BE=D0=B5=20=D0=BA=D0=BE=D0=BB=D0=B8=D1=87=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=B2=D0=BE=20=D1=81=D0=B2=D0=B5=D0=B6=D0=B8=D1=85?= =?UTF-8?q?=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B9,=20?= =?UTF-8?q?=D0=B0=20=D0=BD=D0=B5=20=D0=B2=D1=81=D1=8E=20=D0=B8=D1=81=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D1=8E)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/SkypeWeb/src/skype_messages.cpp | 61 ++++++++++++++----------------- 1 file changed, 28 insertions(+), 33 deletions(-) (limited to 'protocols/SkypeWeb/src/skype_messages.cpp') diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index 8ceb243d0a..22ad6918b9 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -93,7 +93,7 @@ bool CSkypeProto::ParseMessage(const JSONNode &node, DB::EventInfo &dbei) CMStringW wszContent = node["content"].as_mstring(); std::string strMessageType = node["messagetype"].as_string(); - if (strMessageType == "RichText/Media_GenericFile") { + if (strMessageType == "RichText/Media_GenericFile" || strMessageType == "RichText/UriObject") { ProcessFileRecv(dbei.hContact, node["content"].as_string().c_str(), dbei); return false; } @@ -152,9 +152,11 @@ void CSkypeProto::ProcessNewMessage(const JSONNode &node) MCONTACT hContact = AddContact(szConversationName, nullptr, true); - time_t timestamp = time(0); // fuck the server time, we need to place events in the order of our local time - if (m_bHistorySynced) - setDword(hContact, "LastMsgTime", timestamp); + if (m_bHistorySynced) { + int64_t lastMsgId = _atoi64(node["id"].as_string().c_str()); + if (lastMsgId > getLastTime(hContact)) + setLastTime(hContact, lastMsgId); + } if (iUserType == 19) if (OnChatEvent(node)) @@ -172,7 +174,7 @@ void CSkypeProto::ProcessNewMessage(const JSONNode &node) DB::EventInfo dbei(db_event_getById(m_szModuleName, szMessageId)); dbei.hContact = hContact; - dbei.timestamp = timestamp; + dbei.timestamp = time(0); dbei.szId = szMessageId; dbei.flags = DBEF_UTF; if (IsMe(szFromSkypename)) @@ -190,20 +192,11 @@ void CSkypeProto::ProcessNewMessage(const JSONNode &node) void CSkypeProto::OnMarkRead(MCONTACT hContact, MEVENT hDbEvent) { - if (IsOnline() && !isChatRoom(hContact)) - MarkMessagesRead(hContact, hDbEvent); -} - -void CSkypeProto::MarkMessagesRead(MCONTACT hContact, MEVENT hDbEvent) -{ - debugLogA(__FUNCTION__); - - DBEVENTINFO dbei = {}; - db_event_get(hDbEvent, &dbei); - time_t timestamp = dbei.timestamp; - - if (getDword(hContact, "LastMsgTime") > (timestamp - 300)) - PushRequest(new MarkMessageReadRequest(getId(hContact), timestamp, timestamp)); + if (IsOnline()) { + DB::EventInfo dbei(hDbEvent, false); + if (dbei && dbei.szId) + PushRequest(new MarkMessageReadRequest(getId(hContact), _atoi64(dbei.szId))); + } } void CSkypeProto::OnReceiveOfflineFile(DB::FILE_BLOB &blob) @@ -247,22 +240,24 @@ void CSkypeProto::ProcessFileRecv(MCONTACT hContact, const char *szContent, DB:: } // ordinary file - if (!mir_strcmp(pszFileType, "File.1")) { - } - else { - debugLogA("Invalid or unsupported file type <%s> ignored", pszFileType); - return; - } + if (!mir_strcmp(pszFileType, "File.1") || !mir_strcmp(pszFileType, "Picture.1")) { + MEVENT hEvent; + dbei.flags |= DBEF_TEMPORARY | DBEF_JSON; + if (dbei) { + DB::FILE_BLOB blob(dbei); + OnReceiveOfflineFile(blob); + blob.write(dbei); + db_event_edit(dbei.getEvent(), &dbei, true); + delete ft; + hEvent = dbei.getEvent(); + } + else hEvent = ProtoChainRecvFile(hContact, DB::FILE_BLOB(ft, ft->fileName), dbei); - dbei.flags |= DBEF_TEMPORARY; - if (dbei) { - DB::FILE_BLOB blob(dbei); - OnReceiveOfflineFile(blob); - blob.write(dbei); - db_event_edit(dbei.getEvent(), &dbei, true); - delete ft; + DBVARIANT dbv = { DBVT_UTF8 }; + dbv.pszVal = (char*)pszFileType; + db_event_setJson(hEvent, "skft", &dbv); } - else ProtoChainRecvFile(hContact, DB::FILE_BLOB(ft, ft->fileName), dbei); + else debugLogA("Invalid or unsupported file type <%s> ignored", pszFileType); } void CSkypeProto::ProcessContactRecv(MCONTACT hContact, const char *szContent, DB::EventInfo &dbei) -- cgit v1.2.3