[PR #3099] [MERGED] Initial Webhook Implementation #6135

Closed
opened 2026-02-05 10:25:14 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/BookStackApp/BookStack/pull/3099
Author: @ssddanbrown
Created: 12/8/2021
Status: Merged
Merged: 12/18/2021
Merged by: @ssddanbrown

Base: masterHead: webhooks


📝 Commits (10+)

  • a3a3055 Started webhook implementation
  • 4621d8b Initial controller/views for webhooks management
  • 8716b19 Completed webhook management interface
  • 6381041 Added testing for webhook management interface
  • f2cb3b9 Added missing migration down table drop
  • 9079700 Refactored the activity service
  • 917598f Added webhook call functionality
  • dbd4281 Added active toggle to webhooks
  • 3bf34b6 Added webhook format example to webhook management views
  • 8d8b458 Updated REST API docs with links to webhooks & theme-systems

📊 Changes

56 files changed (+1368 additions, -187 deletions)

View changed files

📝 .env.example.complete (+1 -2)
app/Actions/ActivityLogger.php (+115 -0)
📝 app/Actions/ActivityQueries.php (+6 -94)
📝 app/Actions/ActivityType.php (+12 -0)
📝 app/Actions/CommentRepo.php (+1 -1)
app/Actions/DispatchWebhookJob.php (+109 -0)
app/Actions/Webhook.php (+75 -0)
app/Actions/WebhookTrackedEvent.php (+18 -0)
📝 app/Auth/UserRepo.php (+0 -9)
📝 app/Config/queue.php (+1 -1)
📝 app/Entities/Models/Entity.php (+10 -1)
📝 app/Entities/Repos/BookRepo.php (+3 -3)
📝 app/Entities/Repos/BookshelfRepo.php (+3 -3)
📝 app/Entities/Repos/ChapterRepo.php (+4 -4)
📝 app/Entities/Repos/PageRepo.php (+5 -5)
📝 app/Entities/Tools/PermissionsUpdater.php (+1 -1)
📝 app/Http/Controllers/Auth/LoginController.php (+1 -1)
📝 app/Http/Controllers/BookController.php (+4 -3)
📝 app/Http/Controllers/BookSortController.php (+1 -1)
📝 app/Http/Controllers/BookshelfController.php (+3 -2)

...and 36 more files

📄 Description

The PR tracks an initial implementation for outbound webhooks. This will adhere-to/include the following:

  • Webhooks will be managed by those that can manage application settings (Generally admin users).
  • They will take a name and endpoint to configure.
  • You can select any system event (As shown in audit log) or choose to send all events.
  • Webhooks will be POST requests with fixed-format JSON.
    • An event property will detail the event that was trigged.
    • A text property will be set where possible to provide a human readable description of the event for potential direct slack (Or slack compatible) usage.
  • No custom permission handling will be considered for this implementation.

TODO

  • Finish admin management UI.
  • Build event call logic.
  • Add example of format to the admin management UI.
  • Add ability to deactivate/activate in the management UI.
  • Mention availability of webhooks in the API docs page.
  • Define strategy for queue based calling (Optional).
  • Testing
    • Permissions
    • Calling
    • Management Interface

Queue Strategy

Defaults to sync. Can use an async queue via QUEUE_CONNECTION=sync. Will then need a queue worker via:

php artisan queue:work --sleep=3 --tries=3 --max-time=3600

Ideally will need that ran via systemd or similar, with php artisan queue:restart ran upon update.

Docs Todo

  • Create new "Notifications & Webhooks" page.
  • Detail changes needed to use database queue where performance is desired.
    • Include a systemd setup steps for a default script-installed Ubuntu setup.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/BookStackApp/BookStack/pull/3099 **Author:** [@ssddanbrown](https://github.com/ssddanbrown) **Created:** 12/8/2021 **Status:** ✅ Merged **Merged:** 12/18/2021 **Merged by:** [@ssddanbrown](https://github.com/ssddanbrown) **Base:** `master` ← **Head:** `webhooks` --- ### 📝 Commits (10+) - [`a3a3055`](https://github.com/BookStackApp/BookStack/commit/a3a30556958e125d33df3c55697c0a8b9273f588) Started webhook implementation - [`4621d8b`](https://github.com/BookStackApp/BookStack/commit/4621d8bcc51d2cba552055151ae6696348231b54) Initial controller/views for webhooks management - [`8716b19`](https://github.com/BookStackApp/BookStack/commit/8716b1922b5a619e1b070184e0a4d7b565cb1f39) Completed webhook management interface - [`6381041`](https://github.com/BookStackApp/BookStack/commit/638104125283209d6e81035741fdbb3d412cf334) Added testing for webhook management interface - [`f2cb3b9`](https://github.com/BookStackApp/BookStack/commit/f2cb3b94f90a33dec2a680d73e02df7a8ddb1fb9) Added missing migration down table drop - [`9079700`](https://github.com/BookStackApp/BookStack/commit/90797001701017bb7ecce11ae39bff1411fbdc35) Refactored the activity service - [`917598f`](https://github.com/BookStackApp/BookStack/commit/917598f7c857a07e8a07f92d71e56e2a214142e2) Added webhook call functionality - [`dbd4281`](https://github.com/BookStackApp/BookStack/commit/dbd4281ae80a5be2d631a0c8bd9e8dc29546c92e) Added active toggle to webhooks - [`3bf34b6`](https://github.com/BookStackApp/BookStack/commit/3bf34b6a0dbee3238db3d09ff83613bd9989594d) Added webhook format example to webhook management views - [`8d8b458`](https://github.com/BookStackApp/BookStack/commit/8d8b45860a4227fa1d559ecf672727edd29a4e50) Updated REST API docs with links to webhooks & theme-systems ### 📊 Changes **56 files changed** (+1368 additions, -187 deletions) <details> <summary>View changed files</summary> 📝 `.env.example.complete` (+1 -2) ➕ `app/Actions/ActivityLogger.php` (+115 -0) 📝 `app/Actions/ActivityQueries.php` (+6 -94) 📝 `app/Actions/ActivityType.php` (+12 -0) 📝 `app/Actions/CommentRepo.php` (+1 -1) ➕ `app/Actions/DispatchWebhookJob.php` (+109 -0) ➕ `app/Actions/Webhook.php` (+75 -0) ➕ `app/Actions/WebhookTrackedEvent.php` (+18 -0) 📝 `app/Auth/UserRepo.php` (+0 -9) 📝 `app/Config/queue.php` (+1 -1) 📝 `app/Entities/Models/Entity.php` (+10 -1) 📝 `app/Entities/Repos/BookRepo.php` (+3 -3) 📝 `app/Entities/Repos/BookshelfRepo.php` (+3 -3) 📝 `app/Entities/Repos/ChapterRepo.php` (+4 -4) 📝 `app/Entities/Repos/PageRepo.php` (+5 -5) 📝 `app/Entities/Tools/PermissionsUpdater.php` (+1 -1) 📝 `app/Http/Controllers/Auth/LoginController.php` (+1 -1) 📝 `app/Http/Controllers/BookController.php` (+4 -3) 📝 `app/Http/Controllers/BookSortController.php` (+1 -1) 📝 `app/Http/Controllers/BookshelfController.php` (+3 -2) _...and 36 more files_ </details> ### 📄 Description The PR tracks an initial implementation for outbound webhooks. This will adhere-to/include the following: - Webhooks will be managed by those that can manage application settings (Generally admin users). - They will take a name and endpoint to configure. - You can select any system event (As shown in audit log) or choose to send all events. - Webhooks will be POST requests with fixed-format JSON. - An `event` property will detail the event that was trigged. - A `text` property will be set where possible to provide a human readable description of the event for potential direct slack (Or slack compatible) usage. - No custom permission handling will be considered for this implementation. ### TODO - [x] Finish admin management UI. - [x] Build event call logic. - [x] Add example of format to the admin management UI. - [x] Add ability to deactivate/activate in the management UI. - [x] Mention availability of webhooks in the API docs page. - [x] Define strategy for queue based calling (Optional). - Testing - [x] Permissions - [x] Calling - [x] Management Interface ### Queue Strategy Defaults to `sync`. Can use an async queue via `QUEUE_CONNECTION=sync`. Will then need a queue worker via: ```bash php artisan queue:work --sleep=3 --tries=3 --max-time=3600 ``` Ideally will need that ran via systemd or similar, with `php artisan queue:restart` ran upon update. ### Docs Todo - Create new "Notifications & Webhooks" page. - Detail changes needed to use database queue where performance is desired. - Include a systemd setup steps for a default script-installed Ubuntu setup. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 10:25:14 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#6135