From 54534f6b42bd82856477a5b0554aad331be64d73 Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Wed, 30 Mar 2022 17:59:55 -0600 Subject: [PATCH] historysync: enqueue immediate backfill on INITIAL_BOOTSTRAP --- historysync.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/historysync.go b/historysync.go index cea3203..c7ca570 100644 --- a/historysync.go +++ b/historysync.go @@ -232,7 +232,7 @@ func (user *User) handleHistorySync(reCheckQueue chan bool, evt *waProto.History // If this was the initial bootstrap, enqueue immediate backfills for the // most recent portals. If it's the last history sync event, start // backfilling the rest of the history of the portals. - if user.bridge.Config.Bridge.HistorySync.Backfill && evt.GetSyncType() == waProto.HistorySync_FULL { + if user.bridge.Config.Bridge.HistorySync.Backfill && (evt.GetSyncType() == waProto.HistorySync_INITIAL_BOOTSTRAP || evt.GetSyncType() == waProto.HistorySync_FULL) { nMostRecent := user.bridge.DB.HistorySyncQuery.GetNMostRecentConversations(user.MXID, user.bridge.Config.Bridge.HistorySync.MaxInitialConversations) for i, conv := range nMostRecent { jid, err := types.ParseJID(conv.ConversationID) @@ -242,10 +242,14 @@ func (user *User) handleHistorySync(reCheckQueue chan bool, evt *waProto.History } portal := user.GetPortalByJID(jid) - // Enqueue immediate backfills for the most recent messages first. - user.EnqueueImmedateBackfill(portal, i) - // Enqueue deferred backfills as configured. - user.EnqueueDeferredBackfills(portal, len(nMostRecent), i) + switch evt.GetSyncType() { + case waProto.HistorySync_INITIAL_BOOTSTRAP: + // Enqueue immediate backfills for the most recent messages first. + user.EnqueueImmedateBackfill(portal, i) + case waProto.HistorySync_FULL: + // Enqueue deferred backfills as configured. + user.EnqueueDeferredBackfills(portal, len(nMostRecent), i) + } } // Tell the queue to check for new backfill requests.