aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2024-09-09 14:41:20 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2024-09-09 18:40:45 +0000
commit9470ddbbd546611a7dfdde2bc6a0763920835226 (patch)
treeb23936e3cb337e04b80ffa5a750ad512e452c8b4 /apps
parent6c1a6d17c2e2c295b5a7ffaaa9bec1decab19b0f (diff)
downloadnextcloud-server-9470ddbbd546611a7dfdde2bc6a0763920835226.tar.gz
nextcloud-server-9470ddbbd546611a7dfdde2bc6a0763920835226.zip
feat(webhook_listeners): Add API endpoint to remove all registrations from an AppAPI app
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/webhook_listeners/lib/Controller/WebhooksController.php32
1 files changed, 31 insertions, 1 deletions
diff --git a/apps/webhook_listeners/lib/Controller/WebhooksController.php b/apps/webhook_listeners/lib/Controller/WebhooksController.php
index eeb26b57030..1d5e37cb373 100644
--- a/apps/webhook_listeners/lib/Controller/WebhooksController.php
+++ b/apps/webhook_listeners/lib/Controller/WebhooksController.php
@@ -247,7 +247,7 @@ class WebhooksController extends OCSController {
*
* @return DataResponse<Http::STATUS_OK, bool, array{}>
*
- * 200: Boolean returned whether something was deleted FIXME
+ * 200: Boolean returned whether something was deleted
*
* @throws OCSBadRequestException Bad request
* @throws OCSForbiddenException Insufficient permissions
@@ -269,4 +269,34 @@ class WebhooksController extends OCSController {
throw new OCSException('An internal error occurred', Http::STATUS_INTERNAL_SERVER_ERROR, $e);
}
}
+
+ /**
+ * Remove all existing webhook registration mapped to an AppAPI app id
+ *
+ * @param string $appid id of the app, as in the EX-APP-ID for creation
+ *
+ * @return DataResponse<Http::STATUS_OK, int, array{}>
+ *
+ * 200: Integer number of registrations deleted
+ *
+ * @throws OCSBadRequestException Bad request
+ * @throws OCSForbiddenException Insufficient permissions
+ * @throws OCSException Other error
+ */
+ #[ApiRoute(verb: 'DELETE', url: '/api/v1/webhooks/byappid/{appid}')]
+ #[AuthorizedAdminSetting(settings:Admin::class)]
+ #[AppApiAdminAccessWithoutUser]
+ public function deleteByAppId(string $appid): DataResponse {
+ try {
+ $deletedCount = $this->mapper->deleteByAppId($appid);
+ return new DataResponse($deletedCount);
+ } catch (\UnexpectedValueException $e) {
+ throw new OCSBadRequestException($e->getMessage(), $e);
+ } catch (\DomainException $e) {
+ throw new OCSForbiddenException($e->getMessage(), $e);
+ } catch (\Exception $e) {
+ $this->logger->error('Error when deleting flows for app id ' . $appid, ['exception' => $e]);
+ throw new OCSException('An internal error occurred', Http::STATUS_INTERNAL_SERVER_ERROR, $e);
+ }
+ }
}