-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #279 from pantheon-systems/ag/pcc-1210/support-for…
…-filtering-sent-webhooks-by-event [PCC-1210] Add support for setting preferred webhook events
- Loading branch information
Showing
5 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@pantheon-systems/pcc-cli": patch | ||
--- | ||
|
||
Added support for setting preferred webhook events. Webhook notifications will only be sent on events matching preferred events |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import inquirer from "inquirer"; | ||
import ora from "ora"; | ||
import AddOnApiHelper from "../../../lib/addonApiHelper"; | ||
import { errorHandler } from "../../exceptions"; | ||
|
||
async function configurePreferredWebhookEvents(siteId: string) { | ||
// Fetch available events | ||
const availableEventsSpinner = ora("Fetching available events...").start(); | ||
const availableEvents = | ||
await AddOnApiHelper.fetchAvailableWebhookEvents(siteId); | ||
availableEventsSpinner.succeed("Fetched available events"); | ||
|
||
// Prompt user to select events | ||
const { selectedEvents } = await inquirer.prompt([ | ||
{ | ||
type: "checkbox", | ||
name: "selectedEvents", | ||
message: | ||
"Select events to receive notifications for. Select none to receive notifications for all events.", | ||
choices: availableEvents, | ||
}, | ||
]); | ||
|
||
if (selectedEvents.length === 0) { | ||
console.info( | ||
"No events selected. Your webhook will receive notifications for all events.", | ||
); | ||
} | ||
|
||
// Update events for the site | ||
const updateEventsSpinner = ora("Updating preferred events...").start(); | ||
await AddOnApiHelper.updateSiteConfig(siteId, { | ||
preferredEvents: selectedEvents, | ||
}); | ||
updateEventsSpinner.succeed("Updated preferred events"); | ||
} | ||
|
||
export default errorHandler(configurePreferredWebhookEvents); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters