// 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()
}
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)