summaryrefslogtreecommitdiff
path: root/protocols/Discord/src/server.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-01-19 20:22:23 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-01-19 20:22:23 +0300
commit92e81067e7e81cefcea58f7e91f6d2d8c959fd0d (patch)
tree469906fd6687a406c4ae232d0260ebe5f731c128 /protocols/Discord/src/server.cpp
parent79d4eb2e8e57025219e6c5680a88446c0a047b8f (diff)
Discord:
- added support for channel addition & removal; - added support for reading message acks; - now Miranda reads the whole history, not only first 99 messages -
Diffstat (limited to 'protocols/Discord/src/server.cpp')
-rw-r--r--protocols/Discord/src/server.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp
index ee4aa23204..e8cc6a752f 100644
--- a/protocols/Discord/src/server.cpp
+++ b/protocols/Discord/src/server.cpp
@@ -65,7 +65,8 @@ void CDiscordProto::OnReceiveHistory(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest
SnowFlake lastId = getId(pUser->hContact, DB_KEY_LASTMSGID); // as stored in a database
- for (auto it = root.begin(); it != root.end(); ++it) {
+ int iNumMessages = 0;
+ for (auto it = root.begin(); it != root.end(); ++it, ++iNumMessages) {
JSONNode &p = *it;
SnowFlake authorid = _wtoi64(p["author"]["id"].as_mstring());
@@ -89,6 +90,10 @@ void CDiscordProto::OnReceiveHistory(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest
}
setId(pUser->hContact, DB_KEY_LASTMSGID, lastId);
+
+ // if we fetched 99 messages, but have smth more to go, continue fetching
+ if (iNumMessages == 99 && lastId < pUser->lastMessageId)
+ RetrieveHistory(pUser->hContact, MSG_AFTER, lastId, 99);
}
/////////////////////////////////////////////////////////////////////////////////////////