-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make CalDAV resource sync a service and expose as occ command #35388
Conversation
Signed-off-by: Christoph Wurst <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Psalm found more than 10 potential problems in the proposed changes. Check the Files changed tab for more details.
Signed-off-by: Christoph Wurst <[email protected]>
|
||
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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\ForceRefreshEvent
TODO
Checklist