From 6fe0d9ef671e5f72b9d3a5eca7045d4c5a7bcbd3 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Sun, 28 Jan 2024 12:55:09 +0100 Subject: [PATCH] feat(disable archive): Allow disabling archive functionality also don't display content pane when archive or scraping is disabled fixes #2009 Signed-off-by: Marcel Klehr --- lib/Service/CrawlService.php | 55 ++++++++--------------------- lib/Service/UserSettingsService.php | 12 ++++++- src/components/BookmarkContent.vue | 8 ++++- src/components/Settings.vue | 31 +++++++++++----- src/components/SidebarBookmark.vue | 3 +- 5 files changed, 57 insertions(+), 52 deletions(-) diff --git a/lib/Service/CrawlService.php b/lib/Service/CrawlService.php index 7f61a72eb0..01144f9b56 100644 --- a/lib/Service/CrawlService.php +++ b/lib/Service/CrawlService.php @@ -35,46 +35,18 @@ class CrawlService { public const READ_TIMEOUT = 10; public const UA_FIREFOX = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0'; - /** - * @var BookmarkMapper - */ - private $bookmarkMapper; - /** - * @var BookmarkPreviewer - */ - private $bookmarkPreviewer; - /** - * @var FaviconPreviewer - */ - private $faviconPreviewer; - /** - * @var IConfig - */ - private $config; - private $path; - private $rootFolder; - /** - * @var IL10N - */ - private $l; - /** - * @var MimeTypes - */ - private $mimey; - /** - * @var LoggerInterface - */ - private $logger; + private MimeTypes $mimey; - public function __construct(BookmarkMapper $bookmarkMapper, BookmarkPreviewer $bookmarkPreviewer, FaviconPreviewer $faviconPreviewer, IConfig $config, IRootFolder $rootFolder, IL10N $l, LoggerInterface $logger) { - $this->bookmarkMapper = $bookmarkMapper; - $this->bookmarkPreviewer = $bookmarkPreviewer; - $this->faviconPreviewer = $faviconPreviewer; - $this->config = $config; - $this->rootFolder = $rootFolder; - $this->l = $l; + public function __construct( + private BookmarkMapper $bookmarkMapper, + private BookmarkPreviewer $bookmarkPreviewer, + private FaviconPreviewer $faviconPreviewer, + private IConfig $config, + private IRootFolder $rootFolder, + private IL10N $l, + private LoggerInterface $logger, + private UserSettingsService $userSettingsService) { $this->mimey = new MimeTypes; - $this->logger = $logger; } /** @@ -104,8 +76,11 @@ public function crawl(Bookmark $bookmark): void { } if ($available) { - $this->archiveFile($bookmark, $resp); - $this->archiveContent($bookmark, $resp); + $this->userSettingsService->setUserId($bookmark->getUserId()); + if (((boolean) $this->userSettingsService->get('archive.enabled')) === true) { + $this->archiveFile($bookmark, $resp); + $this->archiveContent($bookmark, $resp); + } $this->bookmarkPreviewer->getImage($bookmark); $this->faviconPreviewer->getImage($bookmark); } diff --git a/lib/Service/UserSettingsService.php b/lib/Service/UserSettingsService.php index 635d9342f0..29ac59d221 100644 --- a/lib/Service/UserSettingsService.php +++ b/lib/Service/UserSettingsService.php @@ -12,7 +12,7 @@ class UserSettingsService { - public const KEYS = ['hasSeenWhatsnew', 'viewMode', 'archive.filePath', 'backup.enabled', 'backup.filePath', 'sorting']; + public const KEYS = ['hasSeenWhatsnew', 'viewMode', 'archive.enabled', 'archive.filePath', 'backup.enabled', 'backup.filePath', 'sorting']; public function __construct( private ?string $userId, @@ -23,6 +23,10 @@ public function __construct( } + public function setUserId(?string $userId): void { + $this->userId = $userId; + } + /** * @param string $key * @return string @@ -40,6 +44,12 @@ public function get(string $key): string { if ($key === 'limit') { return $this->config->getAppValue('bookmarks', 'performance.maxBookmarksperAccount', 0); } + if ($key === 'archive.enabled') { + $default = (string) true; + } + if ($key === 'privacy.enableScraping') { + return $this->config->getAppValue($this->appName, 'privacy.enableScraping', 'false'); + } if ($key === 'archive.filePath') { $default = $this->l->t('Bookmarks'); } diff --git a/src/components/BookmarkContent.vue b/src/components/BookmarkContent.vue index 48c39edb69..59367bfe2a 100644 --- a/src/components/BookmarkContent.vue +++ b/src/components/BookmarkContent.vue @@ -5,7 +5,7 @@ -->