Make CalDAV resource sync a service and expose as occ command#35388
Make CalDAV resource sync a service and expose as occ command#35388ChristophWurst wants to merge 2 commits intomasterfrom
Conversation
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
There was a problem hiding this comment.
Psalm found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
||
| class CalendarResourcesRoomsSyncService { | ||
|
|
||
| /** @var IResourceManager */ |
Check notice
Code scanning / Psalm
DeprecatedClass
| /** @var IResourceManager */ | ||
| private $resourceManager; | ||
|
|
||
| /** @var IRoomManager */ |
Check notice
Code scanning / Psalm
DeprecatedClass
| /** @var CalDavBackend */ | ||
| private $calDavBackend; | ||
|
|
||
| public function __construct(IResourceManager $resourceManager, |
Check notice
Code scanning / Psalm
DeprecatedClass
| private $calDavBackend; | ||
|
|
||
| public function __construct(IResourceManager $resourceManager, | ||
| IRoomManager $roomManager, |
Check notice
Code scanning / Psalm
DeprecatedClass
| * Run background-job for one specific backendManager | ||
| * either ResourceManager or RoomManager | ||
| * | ||
| * @param IResourceManager|IRoomManager $backendManager |
Check notice
Code scanning / Psalm
DeprecatedClass
| string $dbTableMetadata, | ||
| string $foreignKey, | ||
| string $principalPrefix): void { | ||
| $backends = $backendManager->getBackends(); |
Check notice
Code scanning / Psalm
DeprecatedMethod
| continue; | ||
| } | ||
|
|
||
| $id = $this->addToCache($dbTable, $backendId, $resource); |
Check notice
Code scanning / Psalm
PossiblyNullArgument
| continue; | ||
| } | ||
|
|
||
| $this->updateCache($dbTable, $id, $resource); |
Check notice
Code scanning / Psalm
PossiblyNullArgument
| $this->syncService = $syncService; | ||
| } | ||
|
|
||
| protected function configure() { |
Check notice
Code scanning / Psalm
MissingReturnType
come-nc
left a comment
There was a problem hiding this comment.
I think using background-job:execute works too in this case, given the job is always planned.
But that requires using background-job:list first to get the id, so I have no real problem with having a specific command for it.
That said we should look into improving background-job:execute to be able to run jobs by class name, and background-job:list to be able so search for jobs without knowing the exact name.
| protected function execute(InputInterface $input, OutputInterface $output): int { | ||
| $this->syncService->sync(); | ||
|
|
||
| return 0; | ||
| } |
There was a problem hiding this comment.
Please avoid silent commands, at least output something in verbose mode.
| private CalendarResourcesRoomsSyncService $syncService; | ||
|
|
||
| public function __construct(CalendarResourcesRoomsSyncService $syncService) { | ||
| parent::__construct(); | ||
| $this->syncService = $syncService; | ||
| } |
There was a problem hiding this comment.
| private CalendarResourcesRoomsSyncService $syncService; | |
| public function __construct(CalendarResourcesRoomsSyncService $syncService) { | |
| parent::__construct(); | |
| $this->syncService = $syncService; | |
| } | |
| public function __construct( | |
| private CalendarResourcesRoomsSyncService $syncService, | |
| ) { | |
| parent::__construct(); | |
| } |
Use the force Luke (if you do not need backports)
Summary
CalDAV resources and rooms are provided by apps. Currently the rooms and resources are read in a background job once an hour. Sometimes one wants to see the changes right away.
By moving the job logic into a reusable service we can also invoke it from an occ command.
This also drops the two unused events that aren't emitted anywhere
\OCP\Calendar\Resource\ForceRefreshEvent\OCP\Calendar\Room\ForceRefreshEventTODO
Checklist