mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-12-14 17:33:48 +01:00
historysync: enqueue immediate backfill on INITIAL_BOOTSTRAP
This commit is contained in:
parent
830c294b91
commit
54534f6b42
1 changed files with 9 additions and 5 deletions
|
@ -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
|
// If this was the initial bootstrap, enqueue immediate backfills for the
|
||||||
// most recent portals. If it's the last history sync event, start
|
// most recent portals. If it's the last history sync event, start
|
||||||
// backfilling the rest of the history of the portals.
|
// 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)
|
nMostRecent := user.bridge.DB.HistorySyncQuery.GetNMostRecentConversations(user.MXID, user.bridge.Config.Bridge.HistorySync.MaxInitialConversations)
|
||||||
for i, conv := range nMostRecent {
|
for i, conv := range nMostRecent {
|
||||||
jid, err := types.ParseJID(conv.ConversationID)
|
jid, err := types.ParseJID(conv.ConversationID)
|
||||||
|
@ -242,11 +242,15 @@ func (user *User) handleHistorySync(reCheckQueue chan bool, evt *waProto.History
|
||||||
}
|
}
|
||||||
portal := user.GetPortalByJID(jid)
|
portal := user.GetPortalByJID(jid)
|
||||||
|
|
||||||
|
switch evt.GetSyncType() {
|
||||||
|
case waProto.HistorySync_INITIAL_BOOTSTRAP:
|
||||||
// Enqueue immediate backfills for the most recent messages first.
|
// Enqueue immediate backfills for the most recent messages first.
|
||||||
user.EnqueueImmedateBackfill(portal, i)
|
user.EnqueueImmedateBackfill(portal, i)
|
||||||
|
case waProto.HistorySync_FULL:
|
||||||
// Enqueue deferred backfills as configured.
|
// Enqueue deferred backfills as configured.
|
||||||
user.EnqueueDeferredBackfills(portal, len(nMostRecent), i)
|
user.EnqueueDeferredBackfills(portal, len(nMostRecent), i)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Tell the queue to check for new backfill requests.
|
// Tell the queue to check for new backfill requests.
|
||||||
reCheckQueue <- true
|
reCheckQueue <- true
|
||||||
|
|
Loading…
Reference in a new issue