From 3b1614ff2e7594ddaf254a9efc1a1f04ca6398ae Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Mon, 9 Sep 2024 19:30:51 +0300 Subject: [PATCH 1/4] feat: add unregister of webhook listeners Signed-off-by: Andrey Borysenko --- lib/Service/ExAppService.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/Service/ExAppService.php b/lib/Service/ExAppService.php index d3afdac7..2b39e6de 100644 --- a/lib/Service/ExAppService.php +++ b/lib/Service/ExAppService.php @@ -27,6 +27,8 @@ use OCP\IConfig; use OCP\IUser; use OCP\IUserManager; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\NotFoundExceptionInterface; use Psr\Log\LoggerInterface; use SimpleXMLElement; @@ -121,6 +123,7 @@ public function unregisterExApp(string $appId): bool { $this->exAppArchiveFetcher->removeExAppFolder($appId); $this->eventsListenerService->unregisterExAppEventListeners($appId); $this->occService->unregisterExAppOccCommands($appId); + $this->unregisterExAppWebhooks($appId); $r = $this->exAppMapper->deleteExApp($appId); if ($r !== 1) { $this->logger->error(sprintf('Error while unregistering %s ExApp from the database.', $appId)); @@ -399,4 +402,19 @@ public function removeExAppRoutes(ExApp $exApp): ?ExApp { return null; } } + + private function unregisterExAppWebhooks(string $appId): void + { + // webhook_listeners app since NC30 only + if (version_compare($this->config->getSystemValueString('version', '0.0.0'), '30.0', '<')) { + return; + } + try { + $webhookListenerMapper = \OCP\Server::get(\OCA\WebhookListeners\Db\WebhookListenerMapper::class); + $webhookListenerMapper->deleteByAppId($appId); + } catch (ContainerExceptionInterface | NotFoundExceptionInterface $e) { + } catch (Exception $e) { + $this->logger->debug(sprintf('Error while unregistering ExApp %s webhooks: %s', $appId, $e->getMessage())); + } + } } From 67214ac519d4033b786d760cb4bb05d7cb70ba99 Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Mon, 9 Sep 2024 19:50:03 +0300 Subject: [PATCH 2/4] chore: update changelog Signed-off-by: Andrey Borysenko --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee4b0dd5..e09369f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [3.2.0 - 2024-09-06] +## [3.2.0 - 2024-09-09] ### Added @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - TaskProcessing: fixed bug when provider wasn't removed on unregister. #370 - OCC: ExApp unregister command now doesn't remove volume by default. #381 +- WebhooksListener: added removal of the webhook listeners on ExApp unregister. #382 ### Removed From d0d69538985f449cc473689a5c895549e4e1ba64 Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Mon, 9 Sep 2024 19:50:15 +0300 Subject: [PATCH 3/4] fix(ci): php-cs Signed-off-by: Andrey Borysenko --- lib/Service/ExAppService.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Service/ExAppService.php b/lib/Service/ExAppService.php index 2b39e6de..d1eac019 100644 --- a/lib/Service/ExAppService.php +++ b/lib/Service/ExAppService.php @@ -403,8 +403,7 @@ public function removeExAppRoutes(ExApp $exApp): ?ExApp { } } - private function unregisterExAppWebhooks(string $appId): void - { + private function unregisterExAppWebhooks(string $appId): void { // webhook_listeners app since NC30 only if (version_compare($this->config->getSystemValueString('version', '0.0.0'), '30.0', '<')) { return; From ce8809d2601c85235badff6c588958fb99db489c Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Mon, 9 Sep 2024 19:53:25 +0300 Subject: [PATCH 4/4] fix(ci): psalm ignore UndefinedClass of webhook_listeners app Signed-off-by: Andrey Borysenko --- lib/Service/ExAppService.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Service/ExAppService.php b/lib/Service/ExAppService.php index d1eac019..8a5a37cb 100644 --- a/lib/Service/ExAppService.php +++ b/lib/Service/ExAppService.php @@ -403,6 +403,9 @@ public function removeExAppRoutes(ExApp $exApp): ?ExApp { } } + /** + * @psalm-suppress UndefinedClass + */ private function unregisterExAppWebhooks(string $appId): void { // webhook_listeners app since NC30 only if (version_compare($this->config->getSystemValueString('version', '0.0.0'), '30.0', '<')) {