Skip to content

Commit

Permalink
fixup! feat(dav): dispatch out-of-office started and ended events
Browse files Browse the repository at this point in the history
  • Loading branch information
st3iny committed Nov 13, 2023
1 parent f57d8e7 commit 3862ae8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
20 changes: 1 addition & 19 deletions apps/dav/lib/BackgroundJob/OutOfOfficeEventDispatcherJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\QueuedJob;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IUser;
use OCP\IUserManager;
use OCP\User\Events\OutOfOfficeEndedEvent;
use OCP\User\Events\OutOfOfficeStartedEvent;
Expand All @@ -41,9 +40,6 @@ class OutOfOfficeEventDispatcherJob extends QueuedJob {
public const EVENT_START = 'start';
public const EVENT_END = 'end';

/** @var array<string, IUser> $users */
private array $userCache = [];

public function __construct(
ITimeFactory $time,
private AbsenceMapper $absenceMapper,
Expand All @@ -69,7 +65,7 @@ protected function run($argument) {
}

$userId = $absence->getUserId();
$user = $this->getUser($userId);
$user = $this->userManager->get($userId);
if ($user === null) {
$this->logger->error("Failed to dispatch out-of-office event: User $userId does not exist", [

Check failure on line 70 in apps/dav/lib/BackgroundJob/OutOfOfficeEventDispatcherJob.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedClass

apps/dav/lib/BackgroundJob/OutOfOfficeEventDispatcherJob.php:70:4: UndefinedClass: Class, interface or enum named OCA\Mail\Vendor\Psr\Log\LoggerInterface does not exist (see https://psalm.dev/019)

Check failure

Code scanning / Psalm

UndefinedClass Error

Class, interface or enum named OCA\Mail\Vendor\Psr\Log\LoggerInterface does not exist
'argument' => $argument,
Expand All @@ -88,18 +84,4 @@ protected function run($argument) {
]);
}
}

private function getUser(string $userId): ?IUser {
if (isset($this->userCache[$userId])) {
return $this->userCache[$userId];
}

$user = $this->userManager->get($userId);
if ($user === null) {
return null;
}

$this->userCache[$userId] = $user;
return $user;
}
}
2 changes: 1 addition & 1 deletion apps/dav/lib/Db/AbsenceMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function findById(int $id): Absence {
try {
return $this->findEntity($qb);
} catch (MultipleObjectsReturnedException $e) {
// Won't happen as there is a unique index on user_id
// Won't happen as id is the primary key
throw new \RuntimeException(
'The impossible has happened! The query returned multiple absence settings for one user.',
0,
Expand Down

0 comments on commit 3862ae8

Please sign in to comment.