diff options
author | Anna Larch <anna@nextcloud.com> | 2023-11-24 01:49:30 +0100 |
---|---|---|
committer | Anna Larch <anna@nextcloud.com> | 2023-11-28 15:44:23 +0100 |
commit | e8481e428a91beaf3dd27dc0ec3a25c4ff98a320 (patch) | |
tree | c3e25bf14dda918ab88be1415947c3cc71a3693c /apps/dav/lib/CalDAV/Status | |
parent | e7b1d1f46c576c999ac261b7c48abe1a1a6c9588 (diff) | |
download | nextcloud-server-e8481e428a91beaf3dd27dc0ec3a25c4ff98a320.tar.gz nextcloud-server-e8481e428a91beaf3dd27dc0ec3a25c4ff98a320.zip |
[stable28] enh(userstatus): add OOO automation and remove calendar automation
Signed-off-by: Anna Larch <anna@nextcloud.com>
Diffstat (limited to 'apps/dav/lib/CalDAV/Status')
-rw-r--r-- | apps/dav/lib/CalDAV/Status/Status.php | 17 | ||||
-rw-r--r-- | apps/dav/lib/CalDAV/Status/StatusService.php | 24 |
2 files changed, 20 insertions, 21 deletions
diff --git a/apps/dav/lib/CalDAV/Status/Status.php b/apps/dav/lib/CalDAV/Status/Status.php index d1c35002fcd..da08d3fe285 100644 --- a/apps/dav/lib/CalDAV/Status/Status.php +++ b/apps/dav/lib/CalDAV/Status/Status.php @@ -26,8 +26,7 @@ namespace OCA\DAV\CalDAV\Status; class Status { - - public function __construct(private string $status = '', private ?string $message = null, private ?string $customMessage = null) { + public function __construct(private string $status = '', private ?string $message = null, private ?string $customMessage = null, private ?int $timestamp = null, private ?string $customEmoji = null) { } public function getStatus(): string { @@ -54,5 +53,19 @@ class Status { $this->customMessage = $customMessage; } + public function setEndTime(?int $timestamp): void { + $this->timestamp = $timestamp; + } + + public function getEndTime(): ?int { + return $this->timestamp; + } + public function getCustomEmoji(): ?string { + return $this->customEmoji; + } + + public function setCustomEmoji(?string $emoji): void { + $this->customEmoji = $emoji; + } } diff --git a/apps/dav/lib/CalDAV/Status/StatusService.php b/apps/dav/lib/CalDAV/Status/StatusService.php index 1dce2c4c3a3..eea4c12db23 100644 --- a/apps/dav/lib/CalDAV/Status/StatusService.php +++ b/apps/dav/lib/CalDAV/Status/StatusService.php @@ -66,7 +66,6 @@ use Sabre\VObject\Component; use Sabre\VObject\Component\VEvent; use Sabre\VObject\Parameter; use Sabre\VObject\Property; -use Sabre\VObject\Reader; class StatusService { public function __construct(private ITimeFactory $timeFactory, @@ -76,7 +75,7 @@ class StatusService { private FreeBusyGenerator $generator) { } - public function processCalendarAvailability(User $user, ?string $availability): ?Status { + public function processCalendarAvailability(User $user): ?Status { $userId = $user->getUID(); $email = $user->getEMailAddress(); if($email === null) { @@ -160,8 +159,7 @@ class StatusService { } // @todo we can cache that - if(empty($availability) && empty($calendarEvents)) { - // No availability settings and no calendar events, we can stop here + if(empty($calendarEvents)) { return null; } @@ -181,15 +179,6 @@ class StatusService { $this->generator->setObjects($calendar); $this->generator->setTimeRange($dtStart, $dtEnd); $this->generator->setTimeZone($calendarTimeZone); - - if (!empty($availability)) { - $this->generator->setVAvailability( - Reader::read( - $availability - ) - ); - } - // Generate the intersection of VAVILABILITY and all VEVENTS in all calendars $result = $this->generator->getResult(); if (!isset($result->VFREEBUSY)) { @@ -200,9 +189,8 @@ class StatusService { $freeBusyComponent = $result->VFREEBUSY; $freeBusyProperties = $freeBusyComponent->select('FREEBUSY'); // If there is no FreeBusy property, the time-range is empty and available - // so set the status to online as otherwise we will never recover from a BUSY status if (count($freeBusyProperties) === 0) { - return new Status(IUserStatus::ONLINE); + return null; } /** @var Property $freeBusyProperty */ @@ -220,12 +208,10 @@ class StatusService { } $fbType = $fbTypeParameter->getValue(); switch ($fbType) { + // Ignore BUSY-UNAVAILABLE, that's for the automation case 'BUSY': - return new Status(IUserStatus::BUSY, IUserStatus::MESSAGE_CALENDAR_BUSY, $this->l10n->t('In a meeting')); - case 'BUSY-UNAVAILABLE': - return new Status(IUserStatus::AWAY, IUserStatus::MESSAGE_AVAILABILITY); case 'BUSY-TENTATIVE': - return new Status(IUserStatus::AWAY, IUserStatus::MESSAGE_CALENDAR_BUSY_TENTATIVE); + return new Status(IUserStatus::BUSY, IUserStatus::MESSAGE_CALENDAR_BUSY, $this->l10n->t('In a meeting')); default: return null; } |