diff --git a/sender_worker.go b/sender_worker.go index 91daee5..b01bb62 100644 --- a/sender_worker.go +++ b/sender_worker.go @@ -121,9 +121,11 @@ type MatterbridgeMessage struct { func SendToMatterbridge(events <-chan GenericMessage, s SatelNameGetter, config AppConfig, wg *sync.WaitGroup, logger *log.Logger, tpl *template.Template) <-chan GenericMessage { returnEvents := make(chan GenericMessage) + wg.Add(1) go func() { - wg.Add(1) defer wg.Done() + defer close(returnEvents) + for e := range events { returnEvents <- e for _, matterbridgeConfig := range config.Matterbridge { @@ -145,7 +147,6 @@ func SendToMatterbridge(events <-chan GenericMessage, s SatelNameGetter, config logger.Print("Notified via Matterbridge with result ", res.StatusCode) } } - close(returnEvents) }() return returnEvents