summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/Icq10/src/server.cpp14
-rw-r--r--protocols/Icq10/src/stdafx.h1
2 files changed, 11 insertions, 4 deletions
diff --git a/protocols/Icq10/src/server.cpp b/protocols/Icq10/src/server.cpp
index 02fbaf8ad4..ba78846ca2 100644
--- a/protocols/Icq10/src/server.cpp
+++ b/protocols/Icq10/src/server.cpp
@@ -437,7 +437,7 @@ void CIcqProto::OnGetUserHistory(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pR
if (root.error() != 20000)
return;
- __int64 lastMsgId = getId(hContact, "LastMsgId");
+ __int64 lastMsgId = getId(hContact, DB_KEY_LASTMSGID);
const JSONNode &results = root.results();
for (auto &it : results["messages"]) {
@@ -448,7 +448,7 @@ void CIcqProto::OnGetUserHistory(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pR
lastMsgId = msgId;
}
- setId(hContact, "LastMsgId", lastMsgId);
+ setId(hContact, DB_KEY_LASTMSGID, lastMsgId);
}
void CIcqProto::OnGetUserInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
@@ -571,6 +571,12 @@ void CIcqProto::OnSendMessage(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
}
}
}
+
+ const JSONNode &data = root.data();
+ __int64 msgId = _wtoi64(data["histMsgId"].as_mstring());
+ __int64 lastId = getId(ownMsg->m_hContact, DB_KEY_LASTMSGID);
+ if (msgId > lastId)
+ setId(ownMsg->m_hContact, DB_KEY_LASTMSGID, msgId);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -621,12 +627,12 @@ void CIcqProto::ProcessHistData(const JSONNode &ev)
MCONTACT hContact = CreateContact(dwUin, true);
- __int64 lastMsgId = getId(hContact, "LastMsgId");
+ __int64 lastMsgId = getId(hContact, DB_KEY_LASTMSGID);
__int64 srvlastId = _wtoi64(ev["lastMsgId"].as_mstring());
// on first start we don't load history not to create dups
if (lastMsgId == 0)
- setId(hContact, "LastMsgId", srvlastId);
+ setId(hContact, DB_KEY_LASTMSGID, srvlastId);
// or load missing messages if any
else if (srvlastId > lastMsgId)
RetrieveUserHistory(hContact, srvlastId, lastMsgId);
diff --git a/protocols/Icq10/src/stdafx.h b/protocols/Icq10/src/stdafx.h
index b88a72d112..8e8ec110a4 100644
--- a/protocols/Icq10/src/stdafx.h
+++ b/protocols/Icq10/src/stdafx.h
@@ -82,6 +82,7 @@
#define DB_KEY_ATOKEN "AToken"
#define DB_KEY_RTOKEN "RToken"
#define DB_KEY_RCLIENTID "RClientID"
+#define DB_KEY_LASTMSGID "LastMsgId"
#define DB_KEY_SESSIONKEY "SessionKey"
#include "http.h"