diff --git a/CHANGELOG.md b/CHANGELOG.md index 819d29792..ac167c259 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ You can also check [on GitHub](https://github.com/nextcloud/news/releases), the ## [25.x.x] ### Changed - add explanations for the individual values in the feed information table +- show error message from `opml` import in web-ui ### Fixed - fix proxy port removed if standard port for the protocol (#3027) diff --git a/lib/Controller/ImportController.php b/lib/Controller/ImportController.php index e94e298ba..9403fd14e 100644 --- a/lib/Controller/ImportController.php +++ b/lib/Controller/ImportController.php @@ -14,6 +14,7 @@ namespace OCA\News\Controller; use OCA\News\Service\OpmlService; +use OCA\News\Service\Exceptions\ServiceValidationException; use \OCP\IRequest; use OCP\IUserSession; use OCP\AppFramework\Http\Attribute\NoAdminRequired; @@ -38,7 +39,7 @@ public function __construct( #[NoCSRFRequired] #[NoAdminRequired] - public function opml(): void + public function opml(): array { $data = ''; if (isset($this->request->files['file'])) { @@ -49,6 +50,21 @@ public function opml(): void } - $this->opmlService->import($this->getUserId(), $data); + $status = ''; + $message = ''; + try { + $this->opmlService->import($this->getUserId(), $data); + $status = "ok"; + } catch (ServiceValidationException $e) { + $status = "error"; + $message = $e->getMessage(); + } + + $response = [ + 'status' => $status, + 'message' => $message, + ]; + + return $response; } } diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index 069497280..0ee131d9e 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -540,7 +540,12 @@ export default Vue.extend({ }) if (response.ok) { - showSuccess(t('news', 'File successfully uploaded')) + const data = await response.json() + if (data.status === 'ok') { + showSuccess(t('news', 'File successfully uploaded')) + } else { + showError(data.message, { timeout: -1 }) + } } else { showError(t('news', 'Error uploading the opml file')) }