Add mechanism for Plugins to cancel or modify webhook before it is sent to the API

Description

We can already cancel or modify webhooks when received by the API from clients via plugin using a request filter /Webhooks/Events (WebhooksEventsPOSTRequest), but sometimes it would be more efficient to have the client not even send the webhook to the API, or modify the webhook before being sent (such as removing images from inventory item webhooks).

Attachments

5
  • 02 May 2024, 03:26 am
  • 02 May 2024, 03:26 am
  • 13 Feb 2024, 03:38 am
  • 13 Feb 2024, 03:38 am
  • 10 Feb 2024, 07:19 am

Activity

Monica Holliday 9 May 2024 at 02:13

Passed testing 07.02.01.00 SR19

Scott Pearce 7 May 2024 at 04:50

Worked for me.

Monica Holliday 2 May 2024 at 03:26

Failed testing 07.02.01.00 SR19.

Cancel Webhook is not working.

Steps:

  • Enabled Plugin 'DEV-10614 - Cancel Webhook “.

  • Add a subscription for inventory.updated.

  • Restart REST API.

  • Log out of Jiwa, Log back in.

  • Modify any inventory item.

  • Say “No” to message box.

  • Webhook message is still being generated.

Mike Sheen 10 February 2024 at 07:19
Edited

Done - Plugin REST API version 7.2.1.57

Added a static event plugins can subscribe to, ClientWebhookBegin, which the plugin can signal to cancel by setting the System.ComponentModel.CancelEventArgs.Cancel parameter to true, or plugins can modify the body, eventname, DTO Source Type, DTO Id of the webhook - all happening inside the business logic before the webhook is sent to the API.

Attached plugin DEV-10614 - Cancel Webhook demonstrates the cancelling of a webhook. When enabled, any client operation which would generate a webhook will prompt the user if they wish to allow the webhook:

The prompt will only appear when using the Jiwa application, and not services (so a PATCH to /Inventory will not cause a messagebox).

To test this import and enable the attached plugin, add a subscription to the inventory.updated webhook and in Jiwa modify an inventory item - on save the messagebox appears and answering No will not see the webhook sent to any subscriptions.

Answering No will cause the webhook to not be sent to the API.

Attached plugin DEV-10614 - Remove Inventory Images demonstrates the modification of a webhook. This plugin will remove the inventory picture from the inventory.updated and inventory.created webhooks.

To test this import and enable the attached plugin, add a subscription to the inventory.updated webhook and in Jiwa modify an inventory item with a picture or images - on save the webhook received by the subscribers will not have any images or picture.

A second event, ClientWebhookEnd, can also be handled by a plugin to be informed when the webhook has finished being handled.

Done

Details

Assignee

Reporter

Priority

Components

Fix versions

Created 9 February 2024 at 07:16
Updated 4 June 2024 at 01:06
Resolved 7 May 2024 at 04:50