From 5c5de0bac1bf1bc00c01707f1170446c6d895129 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 10 Mar 2023 09:40:36 +0100 Subject: [PATCH] fix(dav): Handle no next potential toggle in availability detection Fixes: min(): Array must contain at least one element at /var/www/nc/nextcloud/apps/dav/lib/BackgroundJob/UserStatusAutomation.php#142 Signed-off-by: Thomas Citharel --- apps/dav/lib/BackgroundJob/UserStatusAutomation.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/dav/lib/BackgroundJob/UserStatusAutomation.php b/apps/dav/lib/BackgroundJob/UserStatusAutomation.php index 94feadcae93..8edc28c9a69 100644 --- a/apps/dav/lib/BackgroundJob/UserStatusAutomation.php +++ b/apps/dav/lib/BackgroundJob/UserStatusAutomation.php @@ -139,6 +139,13 @@ class UserStatusAutomation extends TimedJob { } } + if (empty($nextPotentialToggles)) { + $this->logger->info('Removing ' . self::class . ' background job for user "' . $userId . '" because the user has no valid availability rules set'); + $this->jobList->remove(self::class, $argument); + $this->manager->revertUserStatus($userId, IUserStatus::MESSAGE_AVAILABILITY, IUserStatus::DND); + return; + } + $nextAutomaticToggle = min($nextPotentialToggles); $this->setLastRunToNextToggleTime($userId, $nextAutomaticToggle - 1); -- 2.39.5