From ec4fb86c9667d7158d6f592985031bef61d9ca0a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 4 Feb 2019 14:10:04 +0300 Subject: fixes #1751 (ICQ10: groupchat double last message on every login) --- protocols/ICQ-WIM/src/proto.h | 2 +- protocols/ICQ-WIM/src/server.cpp | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index 5e0609a4c1..98017ed5a3 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -136,7 +136,7 @@ class CIcqProto : public PROTO void ConnectionFailed(int iReason, int iErrorCode = 0); void GetPermitDeny(void); void MoveContactToGroup(MCONTACT hContact, const wchar_t *pwszGroup, const wchar_t *pwszNewGroup); - void RetrieveUserHistory(MCONTACT, __int64 startMsgId, __int64 endMsgId); + void RetrieveUserHistory(MCONTACT, __int64 startMsgId, __int64 endMsgId = -1); void RetrieveUserInfo(MCONTACT); void SetServerStatus(int iNewStatus); void ShutdownSession(void); diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index 001ada84ca..12a4befbd5 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -373,7 +373,7 @@ void CIcqProto::RetrieveUserHistory(MCONTACT hContact, __int64 startMsgId, __int if (endMsgId == 0) endMsgId = -1; - if (startMsgId >= endMsgId) + if (endMsgId != -1 && startMsgId >= endMsgId) return; auto *pReq = new AsyncHttpRequest(CONN_RAPI, REQUEST_POST, ICQ_ROBUST_SERVER, &CIcqProto::OnGetUserHistory); @@ -885,12 +885,14 @@ void CIcqProto::ProcessHistData(const JSONNode &ev) else hContact = CreateContact(_wtol(wszId), true); __int64 lastMsgId = getId(hContact, DB_KEY_LASTMSGID); - if (lastMsgId == 0) + if (lastMsgId == 0) { lastMsgId = _wtoi64(ev["yours"]["lastRead"].as_mstring()); + setId(hContact, DB_KEY_LASTMSGID, lastMsgId); + } // or load missing messages if any if (ev["unreadCnt"].as_int() > 0) - RetrieveUserHistory(hContact, lastMsgId, _wtoi64(ev["lastMsgId"].as_mstring())); + RetrieveUserHistory(hContact, lastMsgId); // check remote read if (g_bMessageState) { @@ -903,10 +905,6 @@ void CIcqProto::ProcessHistData(const JSONNode &ev) CallService(MS_MESSAGESTATE_UPDATE, hContact, (LPARAM)&data); } } - - for (auto &it : ev["tail"]["messages"]) - ParseMessage(hContact, lastMsgId, it, m_bFirstBos); - setId(hContact, DB_KEY_LASTMSGID, lastMsgId); } void CIcqProto::ProcessImState(const JSONNode &ev) -- cgit v1.2.3