X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/f5c601f1801aaa276f8c335fcb51c373edc0b50c..c781f79f3c8cb9a7577ee1574d196988da2719b3:/daemon_message.go?ds=inline diff --git a/daemon_message.go b/daemon_message.go index b70947d..eade727 100644 --- a/daemon_message.go +++ b/daemon_message.go @@ -65,6 +65,7 @@ func openDaemonMessages(loops []*TurnLoop) (*DaemonMessages, error) { ordered: append([]*TurnLoop(nil), loops...), loops: make(map[string]*TurnLoop), } + for _, loop := range loops { m.loops[loop.agent.config.Name] = loop loop.messages = m @@ -173,6 +174,7 @@ func (m *DaemonMessages) deliver(message *DaemonMessage) error { Source: source, Status: status, }) + loop.Wake(logged) if message.WhatsAppBatch > 0 { @@ -370,6 +372,7 @@ func (m *DaemonMessages) PruneWhatsApp(batches []WhatsAppBatch) error { m.state.WhatsAppBatches = slices.DeleteFunc(m.state.WhatsAppBatches, func(number int) bool { return !held[number] }) + if len(m.state.WhatsAppBatches) == before { return nil }