Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add removal of webhook listeners during ExApp unregister #382

Merged
merged 5 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
20 changes: 20 additions & 0 deletions lib/Service/ExAppService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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()));
}
}
}
Loading