From e1b957e17bc0b588a24971f40553b3723584b2b0 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Wed, 17 Jan 2024 16:15:15 +0100 Subject: fix(userstatus): CALL status should overwrite MEETING status Signed-off-by: Anna Larch --- apps/dav/lib/CalDAV/Status/StatusService.php | 35 +++++++++++++++------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'apps/dav') diff --git a/apps/dav/lib/CalDAV/Status/StatusService.php b/apps/dav/lib/CalDAV/Status/StatusService.php index 3fcd4957fa2..58f2d5883fc 100644 --- a/apps/dav/lib/CalDAV/Status/StatusService.php +++ b/apps/dav/lib/CalDAV/Status/StatusService.php @@ -77,12 +77,13 @@ class StatusService { return; } - $userStatusTimestamp = null; - $currentStatus = null; try { $currentStatus = $this->userStatusService->findByUserId($userId); - $userStatusTimestamp = $currentStatus->getIsUserDefined() ? $currentStatus->getStatusTimestamp() : null; + // Was the status set by anything other than the calendar automation? + $userStatusTimestamp = $currentStatus->getIsUserDefined() && $currentStatus->getMessageId() !== IUserStatus::MESSAGE_CALENDAR_BUSY ? $currentStatus->getStatusTimestamp() : null; } catch (DoesNotExistException) { + $userStatusTimestamp = null; + $currentStatus = null; } if($currentStatus !== null && $currentStatus->getMessageId() === IUserStatus::MESSAGE_CALL @@ -123,19 +124,21 @@ class StatusService { return; } - // One event that fulfills all status conditions is enough - // 1. Not an OOO event - // 2. Current user status was not set after the start of this event - // 3. Event is not set to be transparent - $count = count($applicableEvents); - $this->logger->debug("Found $count applicable event(s), changing user status", ['user' => $userId]); - $this->userStatusService->setUserStatus( - $userId, - IUserStatus::AWAY, - IUserStatus::MESSAGE_CALENDAR_BUSY, - true - ); - + // Only update the status if it's neccesary otherwise we mess up the timestamp + if($currentStatus !== null && $currentStatus->getMessageId() !== IUserStatus::MESSAGE_CALENDAR_BUSY) { + // One event that fulfills all status conditions is enough + // 1. Not an OOO event + // 2. Current user status (that is not a calendar status) was not set after the start of this event + // 3. Event is not set to be transparent + $count = count($applicableEvents); + $this->logger->debug("Found $count applicable event(s), changing user status", ['user' => $userId]); + $this->userStatusService->setUserStatus( + $userId, + IUserStatus::AWAY, + IUserStatus::MESSAGE_CALENDAR_BUSY, + true + ); + } } private function getCalendarEvents(User $user): array { -- cgit v1.2.3