From fd2f3f39e5e68db4635736807581d320d4b3b982 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 4 Mar 2019 11:36:22 +0300 Subject: fixes #1870 completely (ICQ doesn't sync outgoing messages) --- protocols/ICQ-WIM/src/poll.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'protocols/ICQ-WIM/src/poll.cpp') 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) { -- cgit v1.2.3