aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/BackgroundJob/RefreshWebcalJob.php
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2020-02-10 13:52:57 +0100
committerThomas Citharel <tcit@tcit.fr>2020-02-21 12:49:37 +0100
commit354e8c1f2b7ce4e63ff09d8d01187edf9194c7ff (patch)
tree414bef99181b63cc6b2d49c445179b152776dd49 /apps/dav/lib/BackgroundJob/RefreshWebcalJob.php
parent8bbc38765167b134d2307ab5731efebdeb92bbbb (diff)
downloadnextcloud-server-354e8c1f2b7ce4e63ff09d8d01187edf9194c7ff.tar.gz
nextcloud-server-354e8c1f2b7ce4e63ff09d8d01187edf9194c7ff.zip
Introduce a default refresh rate app setting for calendar subscriptions
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'apps/dav/lib/BackgroundJob/RefreshWebcalJob.php')
-rw-r--r--apps/dav/lib/BackgroundJob/RefreshWebcalJob.php16
1 files changed, 13 insertions, 3 deletions
diff --git a/apps/dav/lib/BackgroundJob/RefreshWebcalJob.php b/apps/dav/lib/BackgroundJob/RefreshWebcalJob.php
index 710dd09da86..f1d56775903 100644
--- a/apps/dav/lib/BackgroundJob/RefreshWebcalJob.php
+++ b/apps/dav/lib/BackgroundJob/RefreshWebcalJob.php
@@ -32,6 +32,7 @@ use DateInterval;
use OC\BackgroundJob\Job;
use OCA\DAV\CalDAV\WebcalCaching\RefreshWebcalService;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\IConfig;
use OCP\ILogger;
use Sabre\VObject\DateTimeParser;
use Sabre\VObject\InvalidDataException;
@@ -43,6 +44,11 @@ class RefreshWebcalJob extends Job {
*/
private $refreshWebcalService;
+ /**
+ * @var IConfig
+ */
+ private $config;
+
/** @var ILogger */
private $logger;
@@ -53,11 +59,13 @@ class RefreshWebcalJob extends Job {
* RefreshWebcalJob constructor.
*
* @param RefreshWebcalService $refreshWebcalService
+ * @param IConfig $config
* @param ILogger $logger
* @param ITimeFactory $timeFactory
*/
- public function __construct(RefreshWebcalService $refreshWebcalService, ILogger $logger, ITimeFactory $timeFactory) {
+ public function __construct(RefreshWebcalService $refreshWebcalService, IConfig $config, ILogger $logger, ITimeFactory $timeFactory) {
$this->refreshWebcalService = $refreshWebcalService;
+ $this->config = $config;
$this->logger = $logger;
$this->timeFactory = $timeFactory;
}
@@ -76,12 +84,14 @@ class RefreshWebcalJob extends Job {
$this->fixSubscriptionRowTyping($subscription);
// if no refresh rate was configured, just refresh once a week
+ $defaultRefreshRate = $this->config->getAppValue('dav', 'calendarSubscriptionRefreshRate', 'P1W');
+ $refreshRate = $subscription[RefreshWebcalService::REFRESH_RATE] ?? $defaultRefreshRate;
+
$subscriptionId = $subscription['id'];
- $refreshrate = $subscription[RefreshWebcalService::REFRESH_RATE] ?? 'P1W';
try {
/** @var DateInterval $dateInterval */
- $dateInterval = DateTimeParser::parseDuration($refreshrate);
+ $dateInterval = DateTimeParser::parseDuration($refreshRate);
} catch(InvalidDataException $ex) {
$this->logger->logException($ex);
$this->logger->warning("Subscription $subscriptionId could not be refreshed, refreshrate in database is invalid");