3232use OC \BackgroundJob \Job ;
3333use OCA \DAV \CalDAV \WebcalCaching \RefreshWebcalService ;
3434use OCP \AppFramework \Utility \ITimeFactory ;
35+ use OCP \IConfig ;
3536use OCP \ILogger ;
3637use Sabre \VObject \DateTimeParser ;
3738use Sabre \VObject \InvalidDataException ;
@@ -43,6 +44,11 @@ class RefreshWebcalJob extends Job {
4344 */
4445 private $ refreshWebcalService ;
4546
47+ /**
48+ * @var IConfig
49+ */
50+ private $ config ;
51+
4652 /** @var ILogger */
4753 private $ logger ;
4854
@@ -53,11 +59,13 @@ class RefreshWebcalJob extends Job {
5359 * RefreshWebcalJob constructor.
5460 *
5561 * @param RefreshWebcalService $refreshWebcalService
62+ * @param IConfig $config
5663 * @param ILogger $logger
5764 * @param ITimeFactory $timeFactory
5865 */
59- public function __construct (RefreshWebcalService $ refreshWebcalService , ILogger $ logger , ITimeFactory $ timeFactory ) {
66+ public function __construct (RefreshWebcalService $ refreshWebcalService , IConfig $ config , ILogger $ logger , ITimeFactory $ timeFactory ) {
6067 $ this ->refreshWebcalService = $ refreshWebcalService ;
68+ $ this ->config = $ config ;
6169 $ this ->logger = $ logger ;
6270 $ this ->timeFactory = $ timeFactory ;
6371 }
@@ -76,12 +84,14 @@ public function execute($jobList, ILogger $logger = null) {
7684 $ this ->fixSubscriptionRowTyping ($ subscription );
7785
7886 // if no refresh rate was configured, just refresh once a week
87+ $ defaultRefreshRate = $ this ->config ->getAppValue ('dav ' , 'calendarSubscriptionRefreshRate ' , 'P1W ' );
88+ $ refreshRate = $ subscription [RefreshWebcalService::REFRESH_RATE ] ?? $ defaultRefreshRate ;
89+
7990 $ subscriptionId = $ subscription ['id ' ];
80- $ refreshrate = $ subscription [RefreshWebcalService::REFRESH_RATE ] ?? 'P1W ' ;
8191
8292 try {
8393 /** @var DateInterval $dateInterval */
84- $ dateInterval = DateTimeParser::parseDuration ($ refreshrate );
94+ $ dateInterval = DateTimeParser::parseDuration ($ refreshRate );
8595 } catch (InvalidDataException $ ex ) {
8696 $ this ->logger ->logException ($ ex );
8797 $ this ->logger ->warning ("Subscription $ subscriptionId could not be refreshed, refreshrate in database is invalid " );
0 commit comments