From a24e8382d1a52db4aa73bd8883055960714684d4 Mon Sep 17 00:00:00 2001 From: shunf4 Date: Wed, 6 Oct 2021 23:01:11 +0800 Subject: [PATCH] correctly retrieve latest archived messages per XEP-0313 --- core/account.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/account.cpp b/core/account.cpp index 6784674..035299b 100644 --- a/core/account.cpp +++ b/core/account.cpp @@ -469,6 +469,14 @@ void Core::Account::onContactNeedHistory(const QString& before, const QString& a query.setAfter(after); } } + if (before.size() == 0 && after.size() == 0) { + // https://xmpp.org/extensions/xep-0313.html#sect-idm46556759682304 + // To request the page at the end of the archive + // (i.e. the most recent messages), include just an + // empty element in the RSM part of the query. + // As defined by RSM, this will return the last page of the archive. + query.setBefore(""); + } qDebug() << "Remote query for" << contact->jid << "from" << after << ", to" << before; }