From 023c61b88f3bfdc3829606a17fa3bf9deac600fc Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Tue, 19 Jan 2021 12:30:48 +0100 Subject: Mappers: Implement item purging Signed-off-by: Sean Molenaar --- lib/Service/ItemServiceV2.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'lib/Service') diff --git a/lib/Service/ItemServiceV2.php b/lib/Service/ItemServiceV2.php index 54cefa197..f13b249b8 100644 --- a/lib/Service/ItemServiceV2.php +++ b/lib/Service/ItemServiceV2.php @@ -113,22 +113,25 @@ class ItemServiceV2 extends Service return $this->mapper->findAllForFeed($feedId); } - - - public function purgeOverThreshold(int $threshold = null) + /** + * @param int|null $threshold + * @param bool $removeUnread + * + * @return int|null Amount of deleted items or null if not applicable + */ + public function purgeOverThreshold(int $threshold = null, bool $removeUnread = false): ?int { - - $threshold = (int) $threshold ?? $this->config->getAppValue( + $threshold = (int) ($threshold ?? $this->config->getAppValue( Application::NAME, 'autoPurgeCount', Application::DEFAULT_SETTINGS['autoPurgeCount'] - ); + )); - if ($threshold === 0) { - return ''; + if ($threshold <= 0) { + return null; } - return $this->mapper->deleteOverThreshold($threshold); + return $this->mapper->deleteOverThreshold($threshold, $removeUnread); } /** -- cgit v1.2.3