Gabe Kangas b80ccc4966
WIP
2024-03-25 09:04:05 -07:00

31 lines
911 B
Go

package webhooks
import (
"time"
"github.com/owncast/owncast/models"
"github.com/owncast/owncast/storage/configrepository"
"github.com/teris-io/shortid"
)
// SendStreamStatusEvent will send all webhook destinations the current stream status.
func (w *LiveWebhookManager) SendStreamStatusEvent(eventType models.EventType) {
w.sendStreamStatusEvent(eventType, shortid.MustGenerate(), time.Now())
}
func (w *LiveWebhookManager) sendStreamStatusEvent(eventType models.EventType, id string, timestamp time.Time) {
configRepository := configrepository.Get()
w.SendEventToWebhooks(WebhookEvent{
Type: eventType,
EventData: map[string]interface{}{
"id": id,
"name": configRepository.GetServerName(),
"summary": configRepository.GetServerSummary(),
"streamTitle": configRepository.GetStreamTitle(),
"status": w.getStatus(),
"timestamp": timestamp,
},
})
}