summaryrefslogtreecommitdiffstats
path: root/lib/Service
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2021-01-19 12:30:48 +0100
committerSean Molenaar <SMillerDev@users.noreply.github.com>2021-01-30 18:27:06 +0100
commit023c61b88f3bfdc3829606a17fa3bf9deac600fc (patch)
treee17552831645e05366089ef1f3373a03415c8b6d /lib/Service
parent191860fc7210b51032f3026491ed745508209936 (diff)
Mappers: Implement item purging
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'lib/Service')
-rw-r--r--lib/Service/ItemServiceV2.php21
1 files changed, 12 insertions, 9 deletions
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);
}
/**