owncast/core/webhooks/stream.go
Matthew Donoughe 10055664bb
add tests for webhook events (#2180)
* add tests for webhook events

* atomic.Uint32 is not in Go 1.18
2022-10-09 22:55:54 -07:00

27 lines
730 B
Go

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