0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-05-21 23:38:39 +00:00

Added active toggle to webhooks

To allow easy temporary de-activation without deletion or other
workarounds. Updated tests to cover.
This commit is contained in:
Dan Brown 2021-12-12 17:39:06 +00:00
parent 917598f7c8
commit dbd4281ae8
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
10 changed files with 41 additions and 8 deletions
app/Http/Controllers

View file

@ -43,10 +43,12 @@ class WebhookController extends Controller
$validated = $this->validate($request, [
'name' => ['required', 'max:150'],
'endpoint' => ['required', 'url', 'max:500'],
'events' => ['required', 'array']
'events' => ['required', 'array'],
'active' => ['required'],
]);
$webhook = new Webhook($validated);
$webhook->active = $validated['active'] === 'true';
$webhook->save();
$webhook->updateTrackedEvents(array_values($validated['events']));
@ -75,12 +77,14 @@ class WebhookController extends Controller
$validated = $this->validate($request, [
'name' => ['required', 'max:150'],
'endpoint' => ['required', 'url', 'max:500'],
'events' => ['required', 'array']
'events' => ['required', 'array'],
'active' => ['required'],
]);
/** @var Webhook $webhook */
$webhook = Webhook::query()->findOrFail($id);
$webhook->active = $validated['active'] === 'true';
$webhook->fill($validated)->save();
$webhook->updateTrackedEvents($validated['events']);