diff options
author | George Hazan <ghazan@miranda.im> | 2020-07-15 21:15:37 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-07-15 21:15:37 +0300 |
commit | 9d2b6d67e9c528de492f2c8e4df8fd0fb76b3257 (patch) | |
tree | 195c426bb6540b941f4bda31618929dd121aed23 /protocols/ICQ-WIM | |
parent | d43c7dd74bbadd57fb78d014146fd225fd57c71a (diff) |
ICQ-WIM: fix for temporary contacts processing
Diffstat (limited to 'protocols/ICQ-WIM')
-rw-r--r-- | protocols/ICQ-WIM/src/poll.cpp | 29 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/server.cpp | 2 |
2 files changed, 25 insertions, 6 deletions
diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp index 5e1385ba99..a7774d7b3c 100644 --- a/protocols/ICQ-WIM/src/poll.cpp +++ b/protocols/ICQ-WIM/src/poll.cpp @@ -163,8 +163,11 @@ void CIcqProto::ProcessEvent(const JSONNode &ev) void CIcqProto::ProcessHistData(const JSONNode &ev) { MCONTACT hContact; + bool bVeryBeginning = m_bFirstBos; CMStringW wszId(ev["sn"].as_mstring()); + auto *pCache = FindContactByUIN(wszId); // might be NULL for groupchats + if (IsChat(wszId)) { SESSION_INFO *si = g_chatApi.SM_FindSession(wszId, m_szModuleName); if (si == nullptr) @@ -187,7 +190,15 @@ void CIcqProto::ProcessHistData(const JSONNode &ev) else LoadChatInfo(si); } } - else hContact = CreateContact(wszId, true); + else { + hContact = CreateContact(wszId, true); + + // for temporary contacts that just gonna be created + if (pCache == nullptr) { + bVeryBeginning = true; + pCache = FindContactByUIN(wszId); + } + } // restore reading from the previous point, if we just installed Miranda __int64 lastMsgId = getId(hContact, DB_KEY_LASTMSGID); @@ -199,13 +210,14 @@ void CIcqProto::ProcessHistData(const JSONNode &ev) __int64 patchVersion = _wtoi64(ev["patchVersion"].as_mstring()); setId(hContact, DB_KEY_PATCHVER, patchVersion); - auto *pCache = FindContactByUIN(wszId); // might be NULL for groupchats __int64 srvLastId = _wtoi64(ev["lastMsgId"].as_mstring()); // we load history in the very beginning or if the previous message - if (m_bFirstBos) { - if (pCache) + if (bVeryBeginning) { + if (pCache) { + debugLogA("Setting cache = %lld for %d", srvLastId, hContact); pCache->m_iProcessedMsgId = srvLastId; + } if (srvLastId > lastMsgId) { debugLogA("We need to retrieve history for %S: %lld > %lld", wszId.c_str(), srvLastId, lastMsgId); @@ -214,12 +226,19 @@ void CIcqProto::ProcessHistData(const JSONNode &ev) } else { if (!(pCache && pCache->m_iProcessedMsgId >= srvLastId)) { + if (pCache) + debugLogA("Proceeding with cache for %d: %lld < %lld", hContact, pCache->m_iProcessedMsgId, srvLastId); + else + debugLogA("Proceeding with empty cache for %d", hContact); + for (auto &it : ev["tail"]["messages"]) ParseMessage(hContact, lastMsgId, it, false, true); setId(hContact, DB_KEY_LASTMSGID, lastMsgId); - if (pCache) + if (pCache) { pCache->m_iProcessedMsgId = lastMsgId; + debugLogA("Setting second cache = %lld for %d", srvLastId, hContact); + } } } diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index 0794624c4a..4216c65a40 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -215,7 +215,7 @@ void CIcqProto::MarkAsRead(MCONTACT hContact) m_impl.m_markRead.Start(200); - IcqCacheItem *pCache = FindContactByUIN(GetUserId(hContact)); + auto *pCache = FindContactByUIN(GetUserId(hContact)); if (pCache) { mir_cslock lck(m_csMarkReadQueue); if (m_arMarkReadQueue.indexOf(pCache) == -1) |