]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(ooo): add new ooo status with new emoji 42304/head
authorAnna Larch <anna@nextcloud.com>
Fri, 15 Dec 2023 10:07:09 +0000 (11:07 +0100)
committerAnna Larch <anna@nextcloud.com>
Mon, 18 Dec 2023 10:35:00 +0000 (11:35 +0100)
Signed-off-by: Anna Larch <anna@nextcloud.com>
apps/dav/lib/BackgroundJob/UserStatusAutomation.php
apps/dav/tests/unit/BackgroundJob/UserStatusAutomationTest.php
apps/user_status/lib/Listener/OutOfOfficeStatusListener.php
apps/user_status/lib/Service/PredefinedStatusService.php
apps/user_status/tests/Unit/Service/PredefinedStatusServiceTest.php
lib/public/UserStatus/IUserStatus.php

index 60c53e9bd0874247eda29b5eab929d4f0276aa89..5f88fa122b778a8e125fe9aae272d3d9415a6da5 100644 (file)
@@ -89,7 +89,7 @@ class UserStatusAutomation extends TimedJob {
                        $this->logger->info('Removing ' . self::class . ' background job for user "' . $userId . '" because the user has no valid availability rules and no OOO data set');
                        $this->jobList->remove(self::class, $argument);
                        $this->manager->revertUserStatus($user->getUID(), IUserStatus::MESSAGE_AVAILABILITY, IUserStatus::DND);
-                       $this->manager->revertUserStatus($user->getUID(), IUserStatus::MESSAGE_VACATION, IUserStatus::DND);
+                       $this->manager->revertUserStatus($user->getUID(), IUserStatus::MESSAGE_OUT_OF_OFFICE, IUserStatus::DND);
                        return;
                }
 
@@ -227,7 +227,7 @@ class UserStatusAutomation extends TimedJob {
                if(empty($ooo)) {
                        // Reset the user status if the absence doesn't exist
                        $this->logger->debug('User has no OOO period in effect, reverting DND status if applicable');
-                       $this->manager->revertUserStatus($user->getUID(), IUserStatus::MESSAGE_VACATION, IUserStatus::DND);
+                       $this->manager->revertUserStatus($user->getUID(), IUserStatus::MESSAGE_OUT_OF_OFFICE, IUserStatus::DND);
                        // We need to also run the availability automation
                        return true;
                }
@@ -235,7 +235,7 @@ class UserStatusAutomation extends TimedJob {
                if(!$this->coordinator->isInEffect($ooo)) {
                        // Reset the user status if the absence is (no longer) in effect
                        $this->logger->debug('User has no OOO period in effect, reverting DND status if applicable');
-                       $this->manager->revertUserStatus($user->getUID(), IUserStatus::MESSAGE_VACATION, IUserStatus::DND);
+                       $this->manager->revertUserStatus($user->getUID(), IUserStatus::MESSAGE_OUT_OF_OFFICE, IUserStatus::DND);
 
                        if($ooo->getStartDate() > $this->time->getTime()) {
                                // Set the next run to take place at the start of the ooo period if it is in the future
@@ -250,7 +250,7 @@ class UserStatusAutomation extends TimedJob {
                // 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_VACATION, IUserStatus::DND, true, $ooo->getShortMessage());
+               $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());
index fe6919d8daecb2aae1fd011524ad6a87cc11157b..ad92df238f0387b2fa4d886483104c13d090e18f 100644 (file)
@@ -228,7 +228,7 @@ END:VCALENDAR');
                        ->method('revertUserStatus');
                $this->statusManager->expects(self::once())
                        ->method('setUserStatus')
-                       ->with('user', IUserStatus::MESSAGE_VACATION, IUserStatus::DND, true, $ooo->getShortMessage());
+                       ->with('user', IUserStatus::MESSAGE_OUT_OF_OFFICE, IUserStatus::DND, true, $ooo->getShortMessage());
                $this->config->expects(self::never())
                        ->method('getUserValue');
                $this->time->method('getDateTime')
index 0d793c3f306740ec49f69ec21c10e6829f2e163f..087446d94a70edb9279a0a43757bb8c8e4a23d12 100644 (file)
@@ -53,7 +53,7 @@ class OutOfOfficeStatusListener implements IEventListener {
         */
        public function handle(Event $event): void {
                if($event instanceof OutOfOfficeClearedEvent) {
-                       $this->manager->revertUserStatus($event->getData()->getUser()->getUID(), IUserStatus::MESSAGE_VACATION, IUserStatus::DND);
+                       $this->manager->revertUserStatus($event->getData()->getUser()->getUID(), IUserStatus::MESSAGE_OUT_OF_OFFICE, IUserStatus::DND);
                        $this->jobsList->scheduleAfter(UserStatusAutomation::class, $this->time->getTime(), ['userId' => $event->getData()->getUser()->getUID()]);
                        return;
                }
index c77ca588ebb64f2d8742cdec5164b6104cc9198a..a80f523000116fb8b91a094c13e4db1774301a8f 100644 (file)
@@ -46,6 +46,7 @@ class PredefinedStatusService {
         * @deprecated See \OCP\UserStatus\IUserStatus::MESSAGE_CALL
         */
        public const CALL = 'call';
+       public const OUT_OF_OFFICE = 'out-of-office';
 
        /** @var IL10N */
        private $l10n;
@@ -113,6 +114,13 @@ class PredefinedStatusService {
                                'clearAt' => null,
                                'visible' => false,
                        ],
+                       [
+                               'id' => self::OUT_OF_OFFICE,
+                               'icon' => '🛑',
+                               'message' => $this->getTranslatedStatusForId(self::OUT_OF_OFFICE),
+                               'clearAt' => null,
+                               'visible' => false,
+                       ],
                ];
        }
 
@@ -148,6 +156,9 @@ class PredefinedStatusService {
                        case self::VACATIONING:
                                return '🌴';
 
+                       case self::OUT_OF_OFFICE:
+                               return '🛑';
+
                        case self::REMOTE_WORK:
                                return '🏡';
 
@@ -178,6 +189,9 @@ class PredefinedStatusService {
                        case self::VACATIONING:
                                return $this->l10n->t('Vacationing');
 
+                       case self::OUT_OF_OFFICE:
+                               return $this->l10n->t('Out of office');
+
                        case self::REMOTE_WORK:
                                return $this->l10n->t('Working remotely');
 
@@ -199,6 +213,7 @@ class PredefinedStatusService {
                        self::COMMUTING,
                        self::SICK_LEAVE,
                        self::VACATIONING,
+                       self::OUT_OF_OFFICE,
                        self::REMOTE_WORK,
                        IUserStatus::MESSAGE_CALL,
                        IUserStatus::MESSAGE_AVAILABILITY,
index 0a65256bfacae7e7a61e602fc0d502ad3733e732..c6850621dd8ec1cf036f1fa2e3ad3a80d3d2c85d 100644 (file)
@@ -47,7 +47,7 @@ class PredefinedStatusServiceTest extends TestCase {
        }
 
        public function testGetDefaultStatuses(): void {
-               $this->l10n->expects($this->exactly(6))
+               $this->l10n->expects($this->exactly(7))
                        ->method('t')
                        ->withConsecutive(
                                ['In a meeting'],
@@ -110,6 +110,13 @@ class PredefinedStatusServiceTest extends TestCase {
                                'clearAt' => null,
                                'visible' => false,
                        ],
+                       [
+                               'id' => 'out-of-office',
+                               'icon' => '🛑',
+                               'message' => 'Out of office',
+                               'clearAt' => null,
+                               'visible' => false,
+                       ],
                ], $actual);
        }
 
@@ -195,7 +202,7 @@ class PredefinedStatusServiceTest extends TestCase {
        }
 
        public function testGetDefaultStatusById(): void {
-               $this->l10n->expects($this->exactly(6))
+               $this->l10n->expects($this->exactly(7))
                        ->method('t')
                        ->withConsecutive(
                                ['In a meeting'],
index f5005e5616bf682d8fa5553558fb396408a993ca..f167f9a82eef124993d74679b468769f7d17e6d5 100644 (file)
@@ -81,6 +81,12 @@ interface IUserStatus {
         */
        public const MESSAGE_AVAILABILITY = 'availability';
 
+       /**
+        * @var string
+        * @since 28.0.1
+        */
+       public const MESSAGE_OUT_OF_OFFICE = 'out-of-office';
+
        /**
         * @var string
         * @since 28.0.0