From 36f030922e8afb7974cf3a1c6d86fce93308d159 Mon Sep 17 00:00:00 2001 From: lawnbot Date: Mon, 5 Jan 2026 00:53:30 +0100 Subject: [PATCH 1/2] Add RoomMetadataUpdated webhook --- webhook/consts.go | 1 + webhook/webhook_test.go | 67 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/webhook/consts.go b/webhook/consts.go index 409d11682..8e576431d 100644 --- a/webhook/consts.go +++ b/webhook/consts.go @@ -27,6 +27,7 @@ const authHeader = "Authorization" const ( EventRoomStarted = "room_started" EventRoomFinished = "room_finished" + EventRoomMetadataChanged = "room_metadata_changed" EventParticipantJoined = "participant_joined" EventParticipantLeft = "participant_left" EventParticipantConnectionAborted = "participant_connection_aborted" diff --git a/webhook/webhook_test.go b/webhook/webhook_test.go index bfa90478e..8f1a2f34d 100644 --- a/webhook/webhook_test.go +++ b/webhook/webhook_test.go @@ -346,6 +346,38 @@ func TestURLNotifierFilter(t *testing.T) { webhookCheckInterval, ) }) + + t.Run("room metadata changed", func(t *testing.T) { + urlNotifier := NewURLNotifier(URLNotifierParams{ + URL: testUrl, + APIKey: testAPIKey, + APISecret: testAPISecret, + FilterParams: FilterParams{ + IncludeEvents: []string{EventRoomMetadataChanged}, + }, + Config: URLNotifierConfig{ + QueueSize: 20, + }, + }) + defer urlNotifier.Stop(false) + + numCalled := atomic.Int32{} + s.handler = func(w http.ResponseWriter, r *http.Request) { + numCalled.Inc() + } + + _ = urlNotifier.QueueNotify(context.Background(), &livekit.WebhookEvent{Event: EventRoomMetadataChanged}) + _ = urlNotifier.QueueNotify(context.Background(), &livekit.WebhookEvent{Event: EventRoomStarted}) + _ = urlNotifier.QueueNotify(context.Background(), &livekit.WebhookEvent{Event: EventRoomFinished}) + require.Eventually( + t, + func() bool { + return numCalled.Load() == 1 + }, + 5*time.Second, + webhookCheckInterval, + ) + }) } func newTestNotifier() *URLNotifier { @@ -701,6 +733,8 @@ func TestResourceURLNotifierLifecycle(t *testing.T) { } func TestResourceURLNotifierFilter(t *testing.T) { + InitWebhookStats(prometheus.Labels{}) + s := newServer(testAddr) require.NoError(t, s.Start()) defer s.Stop() @@ -832,6 +866,39 @@ func TestResourceURLNotifierFilter(t *testing.T) { webhookCheckInterval, ) }) + + t.Run("room metadata changed", func(t *testing.T) { + resourceURLNotifier := NewResourceURLNotifier(ResourceURLNotifierParams{ + URL: testUrl, + APIKey: testAPIKey, + APISecret: testAPISecret, + Config: ResourceURLNotifierConfig{ + MaxAge: 200 * time.Millisecond, + MaxDepth: 50, + }, + FilterParams: FilterParams{ + IncludeEvents: []string{EventRoomMetadataChanged}, + }, + }) + defer resourceURLNotifier.Stop(false) + + numCalled := atomic.Int32{} + s.handler = func(w http.ResponseWriter, r *http.Request) { + numCalled.Inc() + } + + _ = resourceURLNotifier.QueueNotify(context.Background(), &livekit.WebhookEvent{Event: EventRoomMetadataChanged}) + _ = resourceURLNotifier.QueueNotify(context.Background(), &livekit.WebhookEvent{Event: EventRoomStarted}) + _ = resourceURLNotifier.QueueNotify(context.Background(), &livekit.WebhookEvent{Event: EventRoomFinished}) + require.Eventually( + t, + func() bool { + return numCalled.Load() == 1 + }, + 5*time.Second, + webhookCheckInterval, + ) + }) } func newTestResourceNotifier(timeout time.Duration, maxAge time.Duration, maxDepth int) *ResourceURLNotifier { From e3e080228fc60480f77e0e9ba49ca51d51ebbc7f Mon Sep 17 00:00:00 2001 From: lawnbot Date: Mon, 5 Jan 2026 01:09:20 +0100 Subject: [PATCH 2/2] Fix duplicate --- webhook/webhook_test.go | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/webhook/webhook_test.go b/webhook/webhook_test.go index 8f1a2f34d..4a0cee3f4 100644 --- a/webhook/webhook_test.go +++ b/webhook/webhook_test.go @@ -366,8 +366,8 @@ func TestURLNotifierFilter(t *testing.T) { numCalled.Inc() } - _ = urlNotifier.QueueNotify(context.Background(), &livekit.WebhookEvent{Event: EventRoomMetadataChanged}) _ = urlNotifier.QueueNotify(context.Background(), &livekit.WebhookEvent{Event: EventRoomStarted}) + _ = urlNotifier.QueueNotify(context.Background(), &livekit.WebhookEvent{Event: EventRoomMetadataChanged}) _ = urlNotifier.QueueNotify(context.Background(), &livekit.WebhookEvent{Event: EventRoomFinished}) require.Eventually( t, @@ -733,8 +733,6 @@ func TestResourceURLNotifierLifecycle(t *testing.T) { } func TestResourceURLNotifierFilter(t *testing.T) { - InitWebhookStats(prometheus.Labels{}) - s := newServer(testAddr) require.NoError(t, s.Start()) defer s.Stop() @@ -866,39 +864,6 @@ func TestResourceURLNotifierFilter(t *testing.T) { webhookCheckInterval, ) }) - - t.Run("room metadata changed", func(t *testing.T) { - resourceURLNotifier := NewResourceURLNotifier(ResourceURLNotifierParams{ - URL: testUrl, - APIKey: testAPIKey, - APISecret: testAPISecret, - Config: ResourceURLNotifierConfig{ - MaxAge: 200 * time.Millisecond, - MaxDepth: 50, - }, - FilterParams: FilterParams{ - IncludeEvents: []string{EventRoomMetadataChanged}, - }, - }) - defer resourceURLNotifier.Stop(false) - - numCalled := atomic.Int32{} - s.handler = func(w http.ResponseWriter, r *http.Request) { - numCalled.Inc() - } - - _ = resourceURLNotifier.QueueNotify(context.Background(), &livekit.WebhookEvent{Event: EventRoomMetadataChanged}) - _ = resourceURLNotifier.QueueNotify(context.Background(), &livekit.WebhookEvent{Event: EventRoomStarted}) - _ = resourceURLNotifier.QueueNotify(context.Background(), &livekit.WebhookEvent{Event: EventRoomFinished}) - require.Eventually( - t, - func() bool { - return numCalled.Load() == 1 - }, - 5*time.Second, - webhookCheckInterval, - ) - }) } func newTestResourceNotifier(timeout time.Duration, maxAge time.Duration, maxDepth int) *ResourceURLNotifier {