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 diff --git a/lib/Service/ExAppService.php b/lib/Service/ExAppService.php index d3afdac7..8a5a37cb 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,21 @@ public function removeExAppRoutes(ExApp $exApp): ?ExApp { return null; } } + + /** + * @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', '<')) { + 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())); + } + } }