aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorAnna Larch <anna@nextcloud.com>2024-01-17 16:15:15 +0100
committerAnna Larch <anna@nextcloud.com>2024-01-24 18:23:21 +0100
commite1b957e17bc0b588a24971f40553b3723584b2b0 (patch)
treebb2976a2c50bd87783b5410fbbbc76f64693eb44 /apps/dav
parent0f48549769e859275c0e676313f069b2833d797c (diff)
downloadnextcloud-server-e1b957e17bc0b588a24971f40553b3723584b2b0.tar.gz
nextcloud-server-e1b957e17bc0b588a24971f40553b3723584b2b0.zip
fix(userstatus): CALL status should overwrite MEETING status
Signed-off-by: Anna Larch <anna@nextcloud.com>
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/CalDAV/Status/StatusService.php35
1 files changed, 19 insertions, 16 deletions
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 {