Trigger the title updated webhook event whenever a title is changed (#2823)
* wip: trigger the title updated webhook event whenever a title is changed * Commit updated API documentation * fix: add STREAM_TITLE_CHANGED to list of valid events * feat: Add support for STREAM_TITLE_CHANGED webhook event on admin dashboard * fix: transmit webhook event after stream has changed to fix race conditions where older title was sent --------- Co-authored-by: Owncast <owncast@owncast.online>
This commit is contained in:
parent
889a40d07e
commit
07c5cabfe8
@ -15,6 +15,7 @@ import (
|
|||||||
"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"
|
||||||
|
"github.com/owncast/owncast/core/webhooks"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
@ -75,6 +76,7 @@ func SetStreamTitle(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
if value != "" {
|
if value != "" {
|
||||||
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)
|
||||||
}
|
}
|
||||||
controllers.WriteSimpleResponse(w, true, "changed")
|
controllers.WriteSimpleResponse(w, true, "changed")
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ const (
|
|||||||
StreamStarted EventType = "STREAM_STARTED"
|
StreamStarted EventType = "STREAM_STARTED"
|
||||||
// StreamStopped represents a stream stopped event.
|
// StreamStopped represents a stream stopped event.
|
||||||
StreamStopped EventType = "STREAM_STOPPED"
|
StreamStopped EventType = "STREAM_STOPPED"
|
||||||
|
// StreamTitleUpdated is the event sent when a stream's title changes.
|
||||||
|
StreamTitleUpdated EventType = "STREAM_TITLE_UPDATED"
|
||||||
// SystemMessageSent is the event sent when a system message is sent.
|
// SystemMessageSent is the event sent when a system message is sent.
|
||||||
SystemMessageSent EventType = "SYSTEM"
|
SystemMessageSent EventType = "SYSTEM"
|
||||||
// ChatDisabled is when a user is explicitly disabled and blocked from using chat.
|
// ChatDisabled is when a user is explicitly disabled and blocked from using chat.
|
||||||
|
File diff suppressed because one or more lines are too long
@ -20,6 +20,8 @@ const (
|
|||||||
StreamStarted EventType = "STREAM_STARTED"
|
StreamStarted EventType = "STREAM_STARTED"
|
||||||
// StreamStopped represents a stream stopped event.
|
// StreamStopped represents a stream stopped event.
|
||||||
StreamStopped EventType = "STREAM_STOPPED"
|
StreamStopped EventType = "STREAM_STOPPED"
|
||||||
|
// StreamTitleUpdated is the event sent when a stream's title changes.
|
||||||
|
StreamTitleUpdated EventType = "STREAM_TITLE_UPDATED"
|
||||||
// SystemMessageSent is the event sent when a system message is sent.
|
// SystemMessageSent is the event sent when a system message is sent.
|
||||||
SystemMessageSent EventType = "SYSTEM"
|
SystemMessageSent EventType = "SYSTEM"
|
||||||
// ChatActionSent is a generic chat action that can be used for anything that doesn't need specific handling or formatting.
|
// ChatActionSent is a generic chat action that can be used for anything that doesn't need specific handling or formatting.
|
||||||
|
@ -23,6 +23,7 @@ var validEvents = []EventType{
|
|||||||
VisibiltyToggled,
|
VisibiltyToggled,
|
||||||
StreamStarted,
|
StreamStarted,
|
||||||
StreamStopped,
|
StreamStopped,
|
||||||
|
StreamTitleUpdated,
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasValidEvents will verify that all the events provided are valid.
|
// HasValidEvents will verify that all the events provided are valid.
|
||||||
|
@ -42,6 +42,11 @@ const availableEvents = {
|
|||||||
},
|
},
|
||||||
STREAM_STARTED: { name: 'Stream started', description: 'When a stream starts', color: 'orange' },
|
STREAM_STARTED: { name: 'Stream started', description: 'When a stream starts', color: 'orange' },
|
||||||
STREAM_STOPPED: { name: 'Stream stopped', description: 'When a stream stops', color: 'cyan' },
|
STREAM_STOPPED: { name: 'Stream stopped', description: 'When a stream stops', color: 'cyan' },
|
||||||
|
STREAM_TITLE_UPDATED: {
|
||||||
|
name: 'Stream title updated',
|
||||||
|
description: 'When a stream title is changed',
|
||||||
|
color: 'yellow',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function convertEventStringToTag(eventString: string) {
|
function convertEventStringToTag(eventString: string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user