Skip to content

Commit f0a44bf

Browse files
authored
feat: add removal of webhook listeners during ExApp unregister (#382)
Resolves: #377 Add webhooks removal during ExApp unregister only for NC30+ version. --------- Signed-off-by: Andrey Borysenko <[email protected]>
1 parent 4a66978 commit f0a44bf

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## [3.2.0 - 2024-09-06]
8+
## [3.2.0 - 2024-09-09]
99

1010
### Added
1111

@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2222

2323
- TaskProcessing: fixed bug when provider wasn't removed on unregister. #370
2424
- OCC: ExApp unregister command now doesn't remove volume by default. #381
25+
- WebhooksListener: added removal of the webhook listeners on ExApp unregister. #382
2526

2627
### Removed
2728

lib/Service/ExAppService.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
use OCP\IConfig;
2828
use OCP\IUser;
2929
use OCP\IUserManager;
30+
use Psr\Container\ContainerExceptionInterface;
31+
use Psr\Container\NotFoundExceptionInterface;
3032
use Psr\Log\LoggerInterface;
3133
use SimpleXMLElement;
3234

@@ -121,6 +123,7 @@ public function unregisterExApp(string $appId): bool {
121123
$this->exAppArchiveFetcher->removeExAppFolder($appId);
122124
$this->eventsListenerService->unregisterExAppEventListeners($appId);
123125
$this->occService->unregisterExAppOccCommands($appId);
126+
$this->unregisterExAppWebhooks($appId);
124127
$r = $this->exAppMapper->deleteExApp($appId);
125128
if ($r !== 1) {
126129
$this->logger->error(sprintf('Error while unregistering %s ExApp from the database.', $appId));
@@ -399,4 +402,21 @@ public function removeExAppRoutes(ExApp $exApp): ?ExApp {
399402
return null;
400403
}
401404
}
405+
406+
/**
407+
* @psalm-suppress UndefinedClass
408+
*/
409+
private function unregisterExAppWebhooks(string $appId): void {
410+
// webhook_listeners app since NC30 only
411+
if (version_compare($this->config->getSystemValueString('version', '0.0.0'), '30.0', '<')) {
412+
return;
413+
}
414+
try {
415+
$webhookListenerMapper = \OCP\Server::get(\OCA\WebhookListeners\Db\WebhookListenerMapper::class);
416+
$webhookListenerMapper->deleteByAppId($appId);
417+
} catch (ContainerExceptionInterface | NotFoundExceptionInterface $e) {
418+
} catch (Exception $e) {
419+
$this->logger->debug(sprintf('Error while unregistering ExApp %s webhooks: %s', $appId, $e->getMessage()));
420+
}
421+
}
402422
}

0 commit comments

Comments
 (0)