From 050edc72ecbe242476549a0ce004833eeb3c9431 Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Fri, 12 Jul 2024 15:31:01 +0300 Subject: [PATCH 1/4] feat(PublicFunctions): add getExApp method Signed-off-by: Andrey Borysenko --- lib/PublicFunctions.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/PublicFunctions.php b/lib/PublicFunctions.php index 5f158b4f..71e250d3 100644 --- a/lib/PublicFunctions.php +++ b/lib/PublicFunctions.php @@ -101,4 +101,25 @@ public function asyncExAppRequestWithUserInit( } return $this->service->requestToExAppAsync($exApp, $route, $userId, $method, $params, $options, $request); } + + /** + * Get basic ExApp info by appid + * + * @param string $appId + * + * @return array ExApp info (appid, version, name, enabled) or error message + */ + public function getExApp(string $appId): array { + $exApp = $this->exAppService->getExApp($appId); + if ($exApp === null) { + return ['error' => sprintf('ExApp `%s` not found', $appId)]; + } + $info = $exApp->jsonSerialize(); + return [ + 'appid' => $info['appid'], + 'version' => $info['version'], + 'name' => $info['name'], + 'enabled' => $info['enabled'], + ]; + } } From bd9bda8be0c1f733b32e3c1cc813b77ed431e0dd Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Fri, 12 Jul 2024 15:37:30 +0300 Subject: [PATCH 2/4] correct logic Signed-off-by: Andrey Borysenko --- lib/PublicFunctions.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/PublicFunctions.php b/lib/PublicFunctions.php index 71e250d3..143b5181 100644 --- a/lib/PublicFunctions.php +++ b/lib/PublicFunctions.php @@ -109,17 +109,17 @@ public function asyncExAppRequestWithUserInit( * * @return array ExApp info (appid, version, name, enabled) or error message */ - public function getExApp(string $appId): array { + public function getExApp(string $appId): ?array { $exApp = $this->exAppService->getExApp($appId); - if ($exApp === null) { - return ['error' => sprintf('ExApp `%s` not found', $appId)]; + if ($exApp !== null) { + $info = $exApp->jsonSerialize(); + return [ + 'appid' => $info['appid'], + 'version' => $info['version'], + 'name' => $info['name'], + 'enabled' => $info['enabled'], + ]; } - $info = $exApp->jsonSerialize(); - return [ - 'appid' => $info['appid'], - 'version' => $info['version'], - 'name' => $info['name'], - 'enabled' => $info['enabled'], - ]; + return null; } } From a84d44c87b9c5b1f45c7da1a10de710f39b929f6 Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Fri, 12 Jul 2024 15:43:14 +0300 Subject: [PATCH 3/4] correct docstring Signed-off-by: Andrey Borysenko --- lib/PublicFunctions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/PublicFunctions.php b/lib/PublicFunctions.php index 143b5181..9b8cb758 100644 --- a/lib/PublicFunctions.php +++ b/lib/PublicFunctions.php @@ -107,7 +107,7 @@ public function asyncExAppRequestWithUserInit( * * @param string $appId * - * @return array ExApp info (appid, version, name, enabled) or error message + * @return array ExApp info (appid, version, name, enabled) or null if no ExApp found */ public function getExApp(string $appId): ?array { $exApp = $this->exAppService->getExApp($appId); From e84f7025034a1cee97da48e2d4e49ca7934515aa Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Fri, 12 Jul 2024 22:40:30 +0300 Subject: [PATCH 4/4] update changelog Signed-off-by: Andrey Borysenko --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d4abed2..b042938d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ Note: Nextcloud 27 is no longer supported since this version. - New OCS API endpoint to setAppInitProgress. The old one is marked as deprecated. #319 - Added default timeout for requestToExApp function set to 3s. #277 +- Added new PublicFunction method `getExApp`. #326 ### Changed