summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_messages.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-08-07 17:19:37 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-08-07 17:19:37 +0300
commit5732a19c7dd15ee2a70fb30b3b27db9514208d2f (patch)
treec414a6c6582bfdf263b36edf31f6bdb249f9788b /protocols/SkypeWeb/src/skype_messages.cpp
parentaf775d509bf12dd75cdc5088a04bd39cae06ef30 (diff)
fixes #4542 (SkypeWeb: Load Server History втягивает только некоторое количество свежих сообщений, а не всю историю)
Diffstat (limited to 'protocols/SkypeWeb/src/skype_messages.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp61
1 files changed, 28 insertions, 33 deletions
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)