aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2023-01-16 17:24:58 +0100
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-10-01 21:28:29 +0200
commit63a16dce36fecc02cc9db42dcae85ae40dc82290 (patch)
tree7c531079870d8725a35b88670d2b84a617ff5d15
parentce22fc1404c9355ca40f2641661ad0b005491602 (diff)
downloaddino-63a16dce36fecc02cc9db42dcae85ae40dc82290.tar.gz
MAM: Fix latest range not being stored in db if it contained a duplicate
-rw-r--r--libdino/src/service/history_sync.vala12
1 files changed, 7 insertions, 5 deletions
diff --git a/libdino/src/service/history_sync.vala b/libdino/src/service/history_sync.vala
index 92a9e9e4..697d8edd 100644
--- a/libdino/src/service/history_sync.vala
+++ b/libdino/src/service/history_sync.vala
@@ -212,16 +212,18 @@ public class Dino.HistorySync {
var query_params = new Xmpp.MessageArchiveManagement.V2.MamQueryParams.query_latest(mam_server, latest_message_time, latest_message_id);
PageRequestResult page_result = yield get_mam_page(account, query_params, null);
+ debug("[%s | %s] Latest page result: %s", account.bare_jid.to_string(), mam_server.to_string(), page_result.page_result.to_string());
- if (page_result.page_result == PageResult.Error || page_result.page_result == PageResult.Duplicate) {
- debug("MAM [%s | %s] Failed fetching latest page %s", mam_server.to_string(), mam_server.to_string(), page_result.page_result.to_string());
+ if (page_result.page_result == PageResult.Error) {
return null;
}
- print(@"MAM result: $(page_result.page_result))\n");
+ // If we get PageResult.Duplicate, we still want to update the db row to the latest message.
// Catchup finished within first page. Update latest db entry.
- if (page_result.page_result in new PageResult[] { PageResult.TargetReached, PageResult.NoMoreMessages } && latest_row_id != -1) {
+ if (latest_row_id != -1 &&
+ page_result.page_result in new PageResult[] { PageResult.TargetReached, PageResult.NoMoreMessages, PageResult.Duplicate }) {
+
if (page_result.stanzas == null || page_result.stanzas.is_empty) return null;
string first_mam_id = page_result.query_result.first;
@@ -265,7 +267,7 @@ public class Dino.HistorySync {
.value(db.mam_catchup.server_jid, mam_server.to_string())
.value(db.mam_catchup.from_id, from_id)
.value(db.mam_catchup.from_time, from_time)
- .value(db.mam_catchup.from_end, false)
+ .value(db.mam_catchup.from_end, page_result.page_result == PageResult.NoMoreMessages)
.value(db.mam_catchup.to_id, to_id)
.value(db.mam_catchup.to_time, to_time)
.perform();