mirror of
https://github.com/owncast/owncast.git
synced 2025-11-01 10:55:57 +08:00
* Initial plan * Add server status as default field in all webhooks Co-authored-by: gabek <414923+gabek@users.noreply.github.com> * Fix goimports linter error by removing trailing whitespace Co-authored-by: gabek <414923+gabek@users.noreply.github.com> * Move serverURL from status object to separate webhook field per feedback Per code review feedback, serverURL is a configuration value, not a status property. This change: - Removes ServerURL from models.Status struct - Adds ServerURL as separate field in WebhookEvent - Populates ServerURL directly when sending webhooks using configrepository.GetServerURL() - Updates all tests to expect new structure This provides the same functionality (server URL in all webhooks) while correctly treating it as configuration rather than status. Co-authored-by: gabek <414923+gabek@users.noreply.github.com> * Add omitempty tag to ServerURL field in WebhookEvent struct Co-authored-by: gabek <414923+gabek@users.noreply.github.com> * Fix webhook duplication by moving status to eventData for all events Co-authored-by: gabek <414923+gabek@users.noreply.github.com> * Restore type safety to webhook EventData using proper typed structs Co-authored-by: gabek <414923+gabek@users.noreply.github.com> * Move ServerURL from top-level WebhookEvent to eventData for all webhook types Co-authored-by: gabek <414923+gabek@users.noreply.github.com> * Update core/webhooks/webhooks.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Create BaseWebhookData struct for common webhook fields using struct embedding Co-authored-by: gabek <414923+gabek@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gabek <414923+gabek@users.noreply.github.com> Co-authored-by: Gabe Kangas <gabek@real-ity.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
40 lines
1016 B
Go
40 lines
1016 B
Go
package webhooks
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/owncast/owncast/core/chat/events"
|
|
"github.com/owncast/owncast/models"
|
|
"github.com/owncast/owncast/persistence/configrepository"
|
|
)
|
|
|
|
func TestSendStreamStatusEvent(t *testing.T) {
|
|
configRepository := configrepository.Get()
|
|
|
|
configRepository.SetServerName("my server")
|
|
configRepository.SetServerSummary("my server where I stream")
|
|
configRepository.SetStreamTitle("my stream")
|
|
|
|
checkPayload(t, models.StreamStarted, func() {
|
|
sendStreamStatusEvent(events.StreamStarted, "id", time.Unix(72, 6).UTC())
|
|
}, `{
|
|
"id": "id",
|
|
"name": "my server",
|
|
"serverURL": "http://localhost:8080",
|
|
"status": {
|
|
"lastConnectTime": null,
|
|
"lastDisconnectTime": null,
|
|
"online": true,
|
|
"overallMaxViewerCount": 420,
|
|
"sessionMaxViewerCount": 69,
|
|
"streamTitle": "my stream",
|
|
"versionNumber": "1.2.3",
|
|
"viewerCount": 5
|
|
},
|
|
"streamTitle": "my stream",
|
|
"summary": "my server where I stream",
|
|
"timestamp": "1970-01-01T00:01:12.000000006Z"
|
|
}`)
|
|
}
|