diff --git a/webhook/consts.go b/webhook/consts.go index 409d1168..8e576431 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 bfa90478..4a0cee3f 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: EventRoomStarted}) + _ = urlNotifier.QueueNotify(context.Background(), &livekit.WebhookEvent{Event: EventRoomMetadataChanged}) + _ = urlNotifier.QueueNotify(context.Background(), &livekit.WebhookEvent{Event: EventRoomFinished}) + require.Eventually( + t, + func() bool { + return numCalled.Load() == 1 + }, + 5*time.Second, + webhookCheckInterval, + ) + }) } func newTestNotifier() *URLNotifier {