diff options
author | Joas Schilling <coding@schilljs.com> | 2024-06-24 16:28:43 +0200 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2024-06-25 09:33:12 +0000 |
commit | 2bd5a534f0b21c356acf0dcedb816d288604fbb5 (patch) | |
tree | 850fd45022ebdd9994b15198e70f57e0496d5ed1 /apps/dav | |
parent | 69561004c701f62bbbe753ea89e67d26a3fa7f01 (diff) | |
download | nextcloud-server-2bd5a534f0b21c356acf0dcedb816d288604fbb5.tar.gz nextcloud-server-2bd5a534f0b21c356acf0dcedb816d288604fbb5.zip |
fix(userstatus): Fix user status automation in real-life scenario
Order of applying:
- Out-of-office
- Availability
- Call
- Meeting
- User status
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/BackgroundJob/UserStatusAutomation.php | 8 | ||||
-rw-r--r-- | apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php | 6 |
2 files changed, 2 insertions, 12 deletions
diff --git a/apps/dav/lib/BackgroundJob/UserStatusAutomation.php b/apps/dav/lib/BackgroundJob/UserStatusAutomation.php index 5f88fa122b7..fcc44432346 100644 --- a/apps/dav/lib/BackgroundJob/UserStatusAutomation.php +++ b/apps/dav/lib/BackgroundJob/UserStatusAutomation.php @@ -216,9 +216,7 @@ class UserStatusAutomation extends TimedJob { return; } - $this->logger->debug('User is currently NOT available, reverting call status if applicable and then setting DND'); - // The DND status automation is more important than the "Away - In call" so we also restore that one if it exists. - $this->manager->revertUserStatus($userId, IUserStatus::MESSAGE_CALL, IUserStatus::AWAY); + $this->logger->debug('User is currently NOT available, reverting call and meeting status if applicable and then setting DND'); $this->manager->setUserStatus($userId, IUserStatus::MESSAGE_AVAILABILITY, IUserStatus::DND, true); $this->logger->debug('User status automation ran'); } @@ -247,10 +245,8 @@ class UserStatusAutomation extends TimedJob { } $this->logger->debug('User is currently in an OOO period, reverting other automated status and setting OOO DND status'); - // Revert both a possible 'CALL - away' and 'office hours - DND' status - $this->manager->revertUserStatus($user->getUID(), IUserStatus::MESSAGE_CALL, IUserStatus::DND); - $this->manager->revertUserStatus($user->getUID(), IUserStatus::MESSAGE_AVAILABILITY, IUserStatus::DND); $this->manager->setUserStatus($user->getUID(), IUserStatus::MESSAGE_OUT_OF_OFFICE, IUserStatus::DND, true, $ooo->getShortMessage()); + // Run at the end of an ooo period to return to availability / regular user status // If it's overwritten by a custom status in the meantime, there's nothing we can do about it $this->setLastRunToNextToggleTime($user->getUID(), $ooo->getEndDate()); diff --git a/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php b/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php index ad92df238f0..c5748d48ba0 100644 --- a/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php +++ b/apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php @@ -125,8 +125,6 @@ class UserStatusAutomationTest extends TestCase { ->willReturn(new \DateTime($currentTime, new \DateTimeZone('UTC'))); $this->logger->expects(self::exactly(4)) ->method('debug'); - $this->statusManager->expects(self::exactly(2)) - ->method('revertUserStatus'); if (!$isAvailable) { $this->statusManager->expects(self::once()) ->method('setUserStatus') @@ -189,8 +187,6 @@ END:VCALENDAR'); ->willReturn('yes'); $this->time->method('getDateTime') ->willReturn(new \DateTime('2023-02-24 13:58:24.479357', new \DateTimeZone('UTC'))); - $this->statusManager->expects($this->exactly(3)) - ->method('revertUserStatus'); $this->jobList->expects($this->once()) ->method('remove') ->with(UserStatusAutomation::class, ['userId' => 'user']); @@ -224,8 +220,6 @@ END:VCALENDAR'); $this->coordinator->expects(self::once()) ->method('isInEffect') ->willReturn(true); - $this->statusManager->expects($this->exactly(2)) - ->method('revertUserStatus'); $this->statusManager->expects(self::once()) ->method('setUserStatus') ->with('user', IUserStatus::MESSAGE_OUT_OF_OFFICE, IUserStatus::DND, true, $ooo->getShortMessage()); |