Skip to content

Commit

Permalink
api: update test to broadcast to specific hook instead of all
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Dec 12, 2023
1 parent 0b14c80 commit 80db10d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion api/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 80db10d

Please sign in to comment.