From 80db10d37f35e95420db41fe4ba8b06fe19a4b8c Mon Sep 17 00:00:00 2001 From: Nate Maninger Date: Tue, 12 Dec 2023 08:10:02 -0800 Subject: [PATCH] api: update test to broadcast to specific hook instead of all --- api/api.go | 2 +- api/endpoints.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/api/api.go b/api/api.go index 9997c714..f06be990 100644 --- a/api/api.go +++ b/api/api.go @@ -120,7 +120,7 @@ type ( RegisterWebHook(callbackURL string, scopes []string) (webhooks.WebHook, error) UpdateWebHook(id int64, callbackURL string, scopes []string) (webhooks.WebHook, error) RemoveWebHook(id int64) error - BroadcastEvent(event string, scope string, data any) error + BroadcastToWebhook(id int64, event, scope string, data interface{}) error } // A RHPSessionReporter reports on RHP session lifecycle events diff --git a/api/endpoints.go b/api/endpoints.go index 672eb6ea..2605522c 100644 --- a/api/endpoints.go +++ b/api/endpoints.go @@ -567,7 +567,12 @@ func (a *api) handlePUTWebhooks(c jape.Context) { } func (a *api) handlePOSTWebhooksTest(c jape.Context) { - if err := a.webhooks.BroadcastEvent("test", webhooks.ScopeTest, nil); err != nil { + var id int64 + if err := c.DecodeParam("id", &id); err != nil { + return + } + + if err := a.webhooks.BroadcastToWebhook(id, "test", webhooks.ScopeTest, nil); err != nil { c.Error(err, http.StatusInternalServerError) return }