X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/a6a82d96b4906e9e1f09f45f69f48124f11ae1bb..5a93b6124068c2a8748fc0bfbb2a2d151815bcf0:/whatsapp_inbox.go?ds=sidebyside diff --git a/whatsapp_inbox.go b/whatsapp_inbox.go index d76e43c..c7fbf51 100644 --- a/whatsapp_inbox.go +++ b/whatsapp_inbox.go @@ -89,12 +89,14 @@ func (i *WhatsAppInbox) due() <-chan time.Time { // first. With all, it closes and logs all batches also during a catch-up. func (i *WhatsAppInbox) deliver(ctx context.Context, l *TurnLoop, link WhatsAppLink, all bool) error { i.mutex.Lock() + catchingUp := i.catchingUp caughtUp := i.caughtUp i.caughtUp = false i.mutex.Unlock() var err error + switch { case all || caughtUp: err = i.state.CloseAll() @@ -109,6 +111,7 @@ func (i *WhatsAppInbox) deliver(ctx context.Context, l *TurnLoop, link WhatsAppL } var turns []Message + for _, batch := range i.state.Closed() { if batch.Chat.Group && batch.Chat.Name == "" { batch.Chat.Name = i.groups.name(ctx, link, batch.Chat.ID)