Skip to content

Commit 0fca883

Browse files
refactor: Apply rector changes
Signed-off-by: GitHub <noreply@github.com>
1 parent d6e6ad5 commit 0fca883

91 files changed

Lines changed: 427 additions & 272 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/comments/lib/MaxAutoCompleteResultsInitialState.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
namespace OCA\Comments;
1111

1212
use OCP\AppFramework\Services\InitialStateProvider;
13+
use OCP\IAppConfig;
1314
use OCP\IConfig;
1415

1516
class MaxAutoCompleteResultsInitialState extends InitialStateProvider {
1617
public function __construct(
1718
private IConfig $config,
19+
private IAppConfig $appConfig,
1820
) {
1921
}
2022

@@ -25,6 +27,6 @@ public function getKey(): string {
2527

2628
#[\Override]
2729
public function getData(): int {
28-
return (int)$this->config->getAppValue('comments', 'maxAutoCompleteResults', '10');
30+
return (int)$this->appConfig->getValue('comments', 'maxAutoCompleteResults', '10');
2931
}
3032
}

apps/dav/lib/BackgroundJob/EventReminderJob.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use OCA\DAV\CalDAV\Reminder\ReminderService;
1515
use OCP\AppFramework\Utility\ITimeFactory;
1616
use OCP\BackgroundJob\TimedJob;
17+
use OCP\IAppConfig;
1718
use OCP\IConfig;
1819

1920
class EventReminderJob extends TimedJob {
@@ -22,6 +23,7 @@ public function __construct(
2223
ITimeFactory $time,
2324
private ReminderService $reminderService,
2425
private IConfig $config,
26+
private IAppConfig $appConfig,
2527
) {
2628
parent::__construct($time);
2729

@@ -36,11 +38,11 @@ public function __construct(
3638
*/
3739
#[\Override]
3840
public function run($argument):void {
39-
if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') {
41+
if ($this->appConfig->getValue('dav', 'sendEventReminders', 'yes') !== 'yes') {
4042
return;
4143
}
4244

43-
if ($this->config->getAppValue('dav', 'sendEventRemindersMode', 'backgroundjob') !== 'backgroundjob') {
45+
if ($this->appConfig->getValue('dav', 'sendEventRemindersMode', 'backgroundjob') !== 'backgroundjob') {
4446
return;
4547
}
4648

apps/dav/lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use OCA\DAV\CalDAV\BirthdayService;
1313
use OCP\AppFramework\Utility\ITimeFactory;
1414
use OCP\BackgroundJob\QueuedJob;
15+
use OCP\IAppConfig;
1516
use OCP\IConfig;
1617

1718
class GenerateBirthdayCalendarBackgroundJob extends QueuedJob {
@@ -20,6 +21,7 @@ public function __construct(
2021
ITimeFactory $time,
2122
private BirthdayService $birthdayService,
2223
private IConfig $config,
24+
private IAppConfig $appConfig,
2325
) {
2426
parent::__construct($time);
2527
}
@@ -30,7 +32,7 @@ public function run($argument) {
3032
$purgeBeforeGenerating = $argument['purgeBeforeGenerating'] ?? false;
3133

3234
// make sure admin didn't change their mind
33-
$isGloballyEnabled = $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes');
35+
$isGloballyEnabled = $this->appConfig->getValue('dav', 'generateBirthdayCalendar', 'yes');
3436
if ($isGloballyEnabled !== 'yes') {
3537
return;
3638
}

apps/dav/lib/BackgroundJob/PruneOutdatedSyncTokensJob.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use OCA\DAV\CardDAV\CardDavBackend;
1515
use OCP\AppFramework\Utility\ITimeFactory;
1616
use OCP\BackgroundJob\TimedJob;
17+
use OCP\IAppConfig;
1718
use OCP\IConfig;
1819
use Psr\Log\LoggerInterface;
1920

@@ -25,6 +26,7 @@ public function __construct(
2526
private CardDavBackend $cardDavBackend,
2627
private IConfig $config,
2728
private LoggerInterface $logger,
29+
private IAppConfig $appConfig,
2830
) {
2931
parent::__construct($timeFactory);
3032
$this->setInterval(60 * 60 * 24); // One day
@@ -33,8 +35,8 @@ public function __construct(
3335

3436
#[\Override]
3537
public function run($argument) {
36-
$limit = max(1, (int)$this->config->getAppValue(Application::APP_ID, 'totalNumberOfSyncTokensToKeep', '10000'));
37-
$retention = max(7, (int)$this->config->getAppValue(Application::APP_ID, 'syncTokensRetentionDays', '60')) * 24 * 3600;
38+
$limit = max(1, (int)$this->appConfig->getValue(Application::APP_ID, 'totalNumberOfSyncTokensToKeep', '10000'));
39+
$retention = max(7, (int)$this->appConfig->getValue(Application::APP_ID, 'syncTokensRetentionDays', '60')) * 24 * 3600;
3840

3941
$prunedCalendarSyncTokens = $this->calDavBackend->pruneOutdatedSyncTokens($limit, $retention);
4042
$prunedAddressBookSyncTokens = $this->cardDavBackend->pruneOutdatedSyncTokens($limit, $retention);

apps/dav/lib/BackgroundJob/RefreshWebcalJob.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use OCP\AppFramework\Utility\ITimeFactory;
1515
use OCP\BackgroundJob\IJobList;
1616
use OCP\BackgroundJob\Job;
17+
use OCP\IAppConfig;
1718
use OCP\IConfig;
1819
use Psr\Log\LoggerInterface;
1920
use Sabre\VObject\DateTimeParser;
@@ -25,6 +26,7 @@ public function __construct(
2526
private IConfig $config,
2627
private LoggerInterface $logger,
2728
ITimeFactory $timeFactory,
29+
private IAppConfig $appConfig,
2830
) {
2931
parent::__construct($timeFactory);
3032
}
@@ -44,7 +46,7 @@ public function start(IJobList $jobList): void {
4446
$this->fixSubscriptionRowTyping($subscription);
4547

4648
// if no refresh rate was configured, just refresh once a day
47-
$defaultRefreshRate = $this->config->getAppValue('dav', 'calendarSubscriptionRefreshRate', 'P1D');
49+
$defaultRefreshRate = $this->appConfig->getValue('dav', 'calendarSubscriptionRefreshRate', 'P1D');
4850
$refreshRate = $subscription[RefreshWebcalService::REFRESH_RATE] ?? $defaultRefreshRate;
4951

5052
$subscriptionId = $subscription['id'];

apps/dav/lib/CalDAV/BirthdayService.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Exception;
1414
use OCA\DAV\CardDAV\CardDavBackend;
1515
use OCA\DAV\DAV\GroupPrincipalBackend;
16+
use OCP\IAppConfig;
1617
use OCP\IConfig;
1718
use OCP\IDBConnection;
1819
use OCP\IL10N;
@@ -43,6 +44,7 @@ public function __construct(
4344
private IConfig $config,
4445
private IDBConnection $dbConnection,
4546
private IL10N $l10n,
47+
private IAppConfig $appConfig,
4648
) {
4749
}
4850

@@ -375,7 +377,7 @@ private function updateCalendar(string $cardUri,
375377
* @return bool
376378
*/
377379
private function isGloballyEnabled():bool {
378-
return $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes') === 'yes';
380+
return $this->appConfig->getValue('dav', 'generateBirthdayCalendar', 'yes') === 'yes';
379381
}
380382

381383
/**

apps/dav/lib/CalDAV/CalDavBackend.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
use OCP\DB\Exception;
4646
use OCP\DB\QueryBuilder\IQueryBuilder;
4747
use OCP\EventDispatcher\IEventDispatcher;
48+
use OCP\IAppConfig;
4849
use OCP\ICache;
4950
use OCP\ICacheFactory;
5051
use OCP\IConfig;
@@ -220,6 +221,7 @@ public function __construct(
220221
private FederatedCalendarMapper $federatedCalendarMapper,
221222
ICacheFactory $cacheFactory,
222223
private bool $legacyEndpoint = false,
224+
private IAppConfig $appConfig,
223225
) {
224226
$this->publishStatusCache = $cacheFactory->createInMemory();
225227
}
@@ -943,7 +945,7 @@ public function deleteCalendar($calendarId, bool $forceDeletePermanently = false
943945
// retention (0 seconds) is set, which signals a disabled trashbin.
944946
$calendarData = $this->getCalendarById($calendarId);
945947
$isBirthdayCalendar = isset($calendarData['uri']) && $calendarData['uri'] === BirthdayService::BIRTHDAY_CALENDAR_URI;
946-
$trashbinDisabled = $this->config->getAppValue(Application::APP_ID, RetentionService::RETENTION_CONFIG_KEY) === '0';
948+
$trashbinDisabled = $this->appConfig->getValue(Application::APP_ID, RetentionService::RETENTION_CONFIG_KEY) === '0';
947949
if ($forceDeletePermanently || $isBirthdayCalendar || $trashbinDisabled) {
948950
$calendarData = $this->getCalendarById($calendarId);
949951
$shares = $this->getShares($calendarId);
@@ -1775,7 +1777,7 @@ public function deleteCalendarObject($calendarId, $objectUri, $calendarType = se
17751777
return;
17761778
}
17771779

1778-
if ($forceDeletePermanently || $this->config->getAppValue(Application::APP_ID, RetentionService::RETENTION_CONFIG_KEY) === '0') {
1780+
if ($forceDeletePermanently || $this->appConfig->getValue(Application::APP_ID, RetentionService::RETENTION_CONFIG_KEY) === '0') {
17791781
$qb = $this->db->getQueryBuilder();
17801782
$qb->delete('calendarobjects')
17811783
->where($qb->expr()->eq('calendarid', $qb->createNamedParameter($calendarId)))

apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace OCA\DAV\CalDAV\ICSExportPlugin;
99

10+
use OCP\IAppConfig;
1011
use OCP\IConfig;
1112
use Psr\Log\LoggerInterface;
1213
use Sabre\HTTP\ResponseInterface;
@@ -29,6 +30,7 @@ class ICSExportPlugin extends \Sabre\CalDAV\ICSExportPlugin {
2930
public function __construct(
3031
private IConfig $config,
3132
private LoggerInterface $logger,
33+
private IAppConfig $appConfig,
3234
) {
3335
}
3436

@@ -38,7 +40,7 @@ public function __construct(
3840
#[\Override]
3941
protected function generateResponse($path, $start, $end, $expand, $componentType, $format, $properties, ResponseInterface $response) {
4042
if (!isset($properties['{http://nextcloud.com/ns}refresh-interval'])) {
41-
$value = $this->config->getAppValue('dav', 'defaultRefreshIntervalExportedCalendars', self::DEFAULT_REFRESH_INTERVAL);
43+
$value = $this->appConfig->getValue('dav', 'defaultRefreshIntervalExportedCalendars', self::DEFAULT_REFRESH_INTERVAL);
4244
$properties['{http://nextcloud.com/ns}refresh-interval'] = $value;
4345
}
4446

apps/dav/lib/CalDAV/Outbox.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace OCA\DAV\CalDAV;
1111

12+
use OCP\IAppConfig;
1213
use OCP\IConfig;
1314
use Sabre\CalDAV\Plugin as CalDAVPlugin;
1415

@@ -31,6 +32,7 @@ class Outbox extends \Sabre\CalDAV\Schedule\Outbox {
3132
public function __construct(
3233
private IConfig $config,
3334
string $principalUri,
35+
private IAppConfig $appConfig,
3436
) {
3537
parent::__construct($principalUri);
3638
}
@@ -51,7 +53,7 @@ public function __construct(
5153
public function getACL() {
5254
// getACL is called so frequently that we cache the config result
5355
if ($this->disableFreeBusy === null) {
54-
$this->disableFreeBusy = ($this->config->getAppValue('dav', 'disableFreeBusy', 'no') === 'yes');
56+
$this->disableFreeBusy = ($this->appConfig->getValue('dav', 'disableFreeBusy', 'no') === 'yes');
5557
}
5658

5759
$commonAcl = [

apps/dav/lib/CalDAV/Publishing/PublishPlugin.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use OCA\DAV\CalDAV\CalendarHome;
1313
use OCA\DAV\CalDAV\Publishing\Xml\Publisher;
1414
use OCP\AppFramework\Http;
15+
use OCP\IAppConfig;
1516
use OCP\IConfig;
1617
use OCP\IURLGenerator;
1718
use Sabre\CalDAV\Xml\Property\AllowedSharingModes;
@@ -48,6 +49,7 @@ public function __construct(
4849
* URL Generator for absolute URLs.
4950
*/
5051
protected IURLGenerator $urlGenerator,
52+
private IAppConfig $appConfig,
5153
) {
5254
}
5355

@@ -126,7 +128,7 @@ public function propFind(PropFind $propFind, INode $node) {
126128
$canShare = (!$node->isSubscription() && $node->canWrite());
127129
$canPublish = (!$node->isSubscription() && $node->canWrite());
128130

129-
if ($this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes') {
131+
if ($this->appConfig->getValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes') {
130132
$canShare = $canShare && ($node->getOwner() === $node->getPrincipalURI());
131133
$canPublish = $canPublish && ($node->getOwner() === $node->getPrincipalURI());
132134
}
@@ -190,7 +192,7 @@ public function httpPost(RequestInterface $request, ResponseInterface $response)
190192
/** @var \Sabre\DAVACL\Plugin $acl */
191193
$acl->checkPrivileges($path, '{DAV:}write');
192194

193-
$limitSharingToOwner = $this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes';
195+
$limitSharingToOwner = $this->appConfig->getValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes';
194196
$isOwner = $acl->getCurrentUserPrincipal() === $node->getOwner();
195197
if ($limitSharingToOwner && !$isOwner) {
196198
return;
@@ -224,7 +226,7 @@ public function httpPost(RequestInterface $request, ResponseInterface $response)
224226
/** @var \Sabre\DAVACL\Plugin $acl */
225227
$acl->checkPrivileges($path, '{DAV:}write');
226228

227-
$limitSharingToOwner = $this->config->getAppValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes';
229+
$limitSharingToOwner = $this->appConfig->getValue('dav', 'limitAddressBookAndCalendarSharingToOwner', 'no') === 'yes';
228230
$isOwner = $acl->getCurrentUserPrincipal() === $node->getOwner();
229231
if ($limitSharingToOwner && !$isOwner) {
230232
return;

0 commit comments

Comments
 (0)