mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-06-01 02:29:06 +02:00
Stop backfill loop when channel is closed
This commit is contained in:
parent
6f635a66fc
commit
2015d6f963
|
@ -87,6 +87,9 @@ func (user *User) handleHistorySyncsLoop() {
|
|||
for {
|
||||
select {
|
||||
case evt := <-user.historySyncs:
|
||||
if evt == nil {
|
||||
return
|
||||
}
|
||||
user.handleHistorySync(user.BackfillQueue, evt.Data)
|
||||
case <-user.enqueueBackfillsTimer.C:
|
||||
user.enqueueAllBackfills()
|
||||
|
@ -97,10 +100,9 @@ func (user *User) handleHistorySyncsLoop() {
|
|||
const EnqueueBackfillsDelay = 30 * time.Second
|
||||
|
||||
func (user *User) enqueueAllBackfills() {
|
||||
user.log.Infofln("%v has passed since the last history sync blob, enqueueing backfills", EnqueueBackfillsDelay)
|
||||
nMostRecent := user.bridge.DB.HistorySync.GetNMostRecentConversations(user.MXID, user.bridge.Config.Bridge.HistorySync.MaxInitialConversations)
|
||||
if len(nMostRecent) > 0 {
|
||||
user.log.Infofln("Got last history sync blob, enqueuing backfills")
|
||||
user.log.Infofln("%v has passed since the last history sync blob, enqueueing backfills for %d chats", EnqueueBackfillsDelay, len(nMostRecent))
|
||||
// Find the portals for all the conversations.
|
||||
portals := []*Portal{}
|
||||
for _, conv := range nMostRecent {
|
||||
|
|
Loading…
Reference in a new issue