|
27 | 27 | use OCP\IConfig; |
28 | 28 | use OCP\IUser; |
29 | 29 | use OCP\IUserManager; |
| 30 | +use Psr\Container\ContainerExceptionInterface; |
| 31 | +use Psr\Container\NotFoundExceptionInterface; |
30 | 32 | use Psr\Log\LoggerInterface; |
31 | 33 | use SimpleXMLElement; |
32 | 34 |
|
@@ -121,6 +123,7 @@ public function unregisterExApp(string $appId): bool { |
121 | 123 | $this->exAppArchiveFetcher->removeExAppFolder($appId); |
122 | 124 | $this->eventsListenerService->unregisterExAppEventListeners($appId); |
123 | 125 | $this->occService->unregisterExAppOccCommands($appId); |
| 126 | + $this->unregisterExAppWebhooks($appId); |
124 | 127 | $r = $this->exAppMapper->deleteExApp($appId); |
125 | 128 | if ($r !== 1) { |
126 | 129 | $this->logger->error(sprintf('Error while unregistering %s ExApp from the database.', $appId)); |
@@ -399,4 +402,21 @@ public function removeExAppRoutes(ExApp $exApp): ?ExApp { |
399 | 402 | return null; |
400 | 403 | } |
401 | 404 | } |
| 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 | + } |
402 | 422 | } |
0 commit comments