mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
Send StreamID in webhooks
This commit is contained in:
parent
d00b435269
commit
655ea319b9
@ -12,6 +12,7 @@ import (
|
||||
|
||||
"github.com/owncast/owncast/activitypub/outbox"
|
||||
"github.com/owncast/owncast/controllers"
|
||||
"github.com/owncast/owncast/core"
|
||||
"github.com/owncast/owncast/core/chat"
|
||||
"github.com/owncast/owncast/core/data"
|
||||
"github.com/owncast/owncast/core/user"
|
||||
@ -75,8 +76,10 @@ func SetStreamTitle(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
if value != "" {
|
||||
streamID := core.GetCurrentBroadcast().StreamID
|
||||
|
||||
sendSystemChatAction(fmt.Sprintf("Stream title changed to **%s**", value), true)
|
||||
go webhooks.SendStreamStatusEvent(models.StreamTitleUpdated)
|
||||
go webhooks.SendStreamStatusEvent(models.StreamTitleUpdated, streamID)
|
||||
}
|
||||
controllers.WriteSimpleResponse(w, true, "changed")
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ func setStreamAsConnected(rtmpOut *io.PipeReader) {
|
||||
setupVideoComponentsForId(streamId)
|
||||
setupLiveTranscoderForId(streamId, rtmpOut)
|
||||
|
||||
go webhooks.SendStreamStatusEvent(models.StreamStarted)
|
||||
go webhooks.SendStreamStatusEvent(models.StreamStarted, streamId)
|
||||
segmentPath := filepath.Join(config.HLSStoragePath, streamId)
|
||||
transcoder.StartThumbnailGenerator(segmentPath, data.FindHighestVideoQualityIndex(_currentBroadcast.OutputSettings))
|
||||
|
||||
@ -126,7 +126,7 @@ func SetStreamAsDisconnected() {
|
||||
stopOnlineCleanupTimer()
|
||||
saveStats()
|
||||
|
||||
go webhooks.SendStreamStatusEvent(models.StreamStopped)
|
||||
go webhooks.SendStreamStatusEvent(models.StreamStopped, _currentBroadcast.StreamID)
|
||||
}
|
||||
|
||||
// StartOfflineCleanupTimer will fire a cleanup after n minutes being disconnected.
|
||||
|
||||
@ -9,11 +9,11 @@ import (
|
||||
)
|
||||
|
||||
// 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, streamID string) {
|
||||
sendStreamStatusEvent(eventType, shortid.MustGenerate(), streamID, time.Now())
|
||||
}
|
||||
|
||||
func sendStreamStatusEvent(eventType models.EventType, id string, timestamp time.Time) {
|
||||
func sendStreamStatusEvent(eventType models.EventType, id, streamID string, timestamp time.Time) {
|
||||
SendEventToWebhooks(WebhookEvent{
|
||||
Type: eventType,
|
||||
EventData: map[string]interface{}{
|
||||
@ -23,6 +23,7 @@ func sendStreamStatusEvent(eventType models.EventType, id string, timestamp time
|
||||
"streamTitle": data.GetStreamTitle(),
|
||||
"status": getStatus(),
|
||||
"timestamp": timestamp,
|
||||
"streamID": streamID,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@ -14,14 +14,17 @@ func TestSendStreamStatusEvent(t *testing.T) {
|
||||
data.SetServerSummary("my server where I stream")
|
||||
data.SetStreamTitle("my stream")
|
||||
|
||||
streamID := "test-stream-id"
|
||||
|
||||
checkPayload(t, models.StreamStarted, func() {
|
||||
sendStreamStatusEvent(events.StreamStarted, "id", time.Unix(72, 6).UTC())
|
||||
sendStreamStatusEvent(events.StreamStarted, "id", streamID, time.Unix(72, 6).UTC())
|
||||
}, `{
|
||||
"id": "id",
|
||||
"name": "my server",
|
||||
"streamTitle": "my stream",
|
||||
"summary": "my server where I stream",
|
||||
"timestamp": "1970-01-01T00:01:12.000000006Z",
|
||||
"streamID": "test-stream-id",
|
||||
"status": {
|
||||
"lastConnectTime": null,
|
||||
"lastDisconnectTime": null,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user