From 1250e2d605845984ea2041ef2bf7de511a970684 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 17 Apr 2022 00:46:15 +0300 Subject: [PATCH] More backfill fixes --- historysync.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/historysync.go b/historysync.go index c513d75..27b711f 100644 --- a/historysync.go +++ b/historysync.go @@ -142,8 +142,8 @@ func (user *User) createOrUpdatePortalAndBackfillWithLock(req *database.Backfill msgs = toBackfill toBackfill = toBackfill[0:0] } else { - msgs = toBackfill[:len(toBackfill)-req.MaxBatchEvents] - toBackfill = toBackfill[len(toBackfill)-req.MaxBatchEvents:] + msgs = toBackfill[:req.MaxBatchEvents] + toBackfill = toBackfill[req.MaxBatchEvents:] } if len(msgs) > 0 { @@ -155,7 +155,7 @@ func (user *User) createOrUpdatePortalAndBackfillWithLock(req *database.Backfill user.log.Debugfln("Finished backfilling %d messages in %s (queue ID: %d)", len(allMsgs), portal.Key.JID, req.QueueID) if len(insertionEventIds) > 0 { portal.sendPostBackfillDummy( - time.Unix(int64(allMsgs[len(allMsgs)-1].GetMessageTimestamp()), 0), + time.Unix(int64(allMsgs[0].GetMessageTimestamp()), 0), insertionEventIds[0]) } user.log.Debugfln("Deleting %d history sync messages after backfilling", len(allMsgs)) @@ -432,7 +432,7 @@ func (portal *Portal) backfill(source *User, messages []*waProto.WebMessageInfo) } } - insertionEventIds := []id.EventID{} + var insertionEventIds []id.EventID if len(historyBatch.Events) > 0 && len(historyBatch.PrevEventID) > 0 { portal.log.Infofln("Sending %d historical messages...", len(historyBatch.Events))