From 661ff4e1b446a374f67c64c7473bf573568a8216 Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Fri, 1 Mar 2024 17:00:57 +0530 Subject: [PATCH] fix: app disable listener now deletes sources for all users - introduce a call to /deleteSourcesByProviderForAllUsers Signed-off-by: Anupam Kumar --- lib/Listener/AppDisableListener.php | 8 +------- lib/Service/LangRopeService.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/Listener/AppDisableListener.php b/lib/Listener/AppDisableListener.php index b71788c..c94c9a8 100644 --- a/lib/Listener/AppDisableListener.php +++ b/lib/Listener/AppDisableListener.php @@ -28,7 +28,6 @@ public function __construct( private ProviderConfigService $configService, private LangRopeService $service, private LoggerInterface $logger, - private ?string $userId, ) { } @@ -37,11 +36,6 @@ public function handle(Event $event): void { return; } - if ($this->userId === null) { - $this->logger->warning('No user id provided for app disable'); - return; - } - foreach ($this->configService->getProviders() as $key => $values) { /** @var string[] */ $identifierValues = explode('__', $key, 2); @@ -58,7 +52,7 @@ public function handle(Event $event): void { } $this->configService->removeProvider($appId, $providerId); - $this->service->deleteSourcesByProvider($this->userId, $key); + $this->service->deleteSourcesByProviderForAllUsers($providerId); } } } diff --git a/lib/Service/LangRopeService.php b/lib/Service/LangRopeService.php index 7040110..82517f1 100644 --- a/lib/Service/LangRopeService.php +++ b/lib/Service/LangRopeService.php @@ -131,6 +131,18 @@ public function deleteSourcesByProvider(string $userId, string $providerKey): vo $this->requestToExApp('/deleteSourcesByProvider', 'POST', $params); } + /** + * @param string $providerKey + * @return void + */ + public function deleteSourcesByProviderForAllUsers(string $providerKey): void { + $params = [ + 'providerKey' => $providerKey, + ]; + + $this->requestToExApp('/deleteSourcesByProviderForAllUsers', 'POST', $params); + } + /** * @param string $userId * @param string[] $sourceNames