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