diff options
Diffstat (limited to 'apps/dav/lib/Service/AbsenceService.php')
-rw-r--r-- | apps/dav/lib/Service/AbsenceService.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/apps/dav/lib/Service/AbsenceService.php b/apps/dav/lib/Service/AbsenceService.php index 7c0d6eec082..3e2a218d52b 100644 --- a/apps/dav/lib/Service/AbsenceService.php +++ b/apps/dav/lib/Service/AbsenceService.php @@ -145,6 +145,22 @@ class AbsenceService { } } + public function getCurrentAbsence(IUser $user): ?IOutOfOfficeData { + try { + $absence = $this->absenceMapper->findByUserId($user->getUID()); + $oooData = $absence->toOutOufOfficeData( + $user, + $this->timezoneService->getUserTimezone($user->getUID()) ?? $this->timezoneService->getDefaultTimezone(), + ); + if ($this->isInEffect($oooData)) { + return $oooData; + } + } catch (DoesNotExistException) { + // Nothing there to process + } + return null; + } + public function isInEffect(IOutOfOfficeData $absence): bool { $now = $this->timeFactory->getTime(); return $absence->getStartDate() <= $now && $absence->getEndDate() >= $now; |