diff options
author | George Hazan <ghazan@miranda.im> | 2019-03-04 11:36:22 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-03-04 11:36:22 +0300 |
commit | fd2f3f39e5e68db4635736807581d320d4b3b982 (patch) | |
tree | bfa9085642fc6e452b41b04f0c00066150f2aa39 /protocols/ICQ-WIM/src/poll.cpp | |
parent | 09cafb6f96be7ccff21742e52887ddc162cc6886 (diff) |
fixes #1870 completely (ICQ doesn't sync outgoing messages)
Diffstat (limited to 'protocols/ICQ-WIM/src/poll.cpp')
-rw-r--r-- | protocols/ICQ-WIM/src/poll.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp index db994cd0cf..9b64bbd99b 100644 --- a/protocols/ICQ-WIM/src/poll.cpp +++ b/protocols/ICQ-WIM/src/poll.cpp @@ -147,16 +147,29 @@ void CIcqProto::ProcessHistData(const JSONNode &ev) } else hContact = CreateContact(wszId, true); + // restore reading from the previous point, if we just installed Miranda __int64 lastMsgId = getId(hContact, DB_KEY_LASTMSGID); if (lastMsgId == 0) { lastMsgId = _wtoi64(ev["yours"]["lastRead"].as_mstring()); setId(hContact, DB_KEY_LASTMSGID, lastMsgId); } - // or load missing messages if any - __int64 srvLastId = _wtoi64(ev["lastMsgId"].as_mstring()); - if (srvLastId > lastMsgId) - RetrieveUserHistory(hContact, lastMsgId); + // we load history in the very beginning or if the previous message + if (m_bFirstBos) { + __int64 srvLastId = _wtoi64(ev["lastMsgId"].as_mstring()); + if (srvLastId > lastMsgId) + RetrieveUserHistory(hContact, lastMsgId); + } + else { + // if the previous message is one that we already have, just parse the tail + __int64 srvOlderId = _wtoi64(ev["tail"]["olderMsgId"].as_mstring()); + if (srvOlderId == lastMsgId) { + for (auto &it : ev["tail"]["messages"]) + ParseMessage(hContact, lastMsgId, it, false); + setId(hContact, DB_KEY_LASTMSGID, lastMsgId); + } + else RetrieveUserHistory(hContact, lastMsgId); + } // check remote read if (g_bMessageState) { |