aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-05-24 14:40:59 +0200
committerJoas Schilling <coding@schilljs.com>2022-07-01 12:33:07 +0200
commit5dee54d70bcd207c9b96a4cf6bb58f82fe9fbba9 (patch)
treef65a1eb9992edc00ebf42e200c16bba1b05dc47a /apps/dav
parentfdcf3eafd614612f5a55a9e03b2370d26dfdedcc (diff)
downloadnextcloud-server-5dee54d70bcd207c9b96a4cf6bb58f82fe9fbba9.tar.gz
nextcloud-server-5dee54d70bcd207c9b96a4cf6bb58f82fe9fbba9.zip
Add status automation
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/BackgroundJob/UserStatusAutomation.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/apps/dav/lib/BackgroundJob/UserStatusAutomation.php b/apps/dav/lib/BackgroundJob/UserStatusAutomation.php
index 21e37571c2b..0ead7aa0514 100644
--- a/apps/dav/lib/BackgroundJob/UserStatusAutomation.php
+++ b/apps/dav/lib/BackgroundJob/UserStatusAutomation.php
@@ -31,6 +31,8 @@ use OCP\BackgroundJob\TimedJob;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
+use OCP\UserStatus\IManager;
+use OCP\UserStatus\IUserStatus;
use Psr\Log\LoggerInterface;
use Sabre\VObject\Component\Available;
use Sabre\VObject\Component\VAvailability;
@@ -41,17 +43,20 @@ class UserStatusAutomation extends TimedJob {
protected IDBConnection $connection;
protected IJobList $jobList;
protected LoggerInterface $logger;
+ protected IManager $manager;
protected IConfig $config;
public function __construct(ITimeFactory $timeFactory,
IDBConnection $connection,
IJobList $jobList,
LoggerInterface $logger,
+ IManager $manager,
IConfig $config) {
parent::__construct($timeFactory);
$this->connection = $connection;
$this->jobList = $jobList;
$this->logger = $logger;
+ $this->manager = $manager;
$this->config = $config;
// Interval 0 might look weird, but the last_checked is always moved
@@ -138,8 +143,13 @@ class UserStatusAutomation extends TimedJob {
$nextAutomaticToggle = min($nextPotentialToggles);
$this->setLastRunToNextToggleTime($userId, $nextAutomaticToggle - 1);
- // FIXME Currently available so disable DND
- $isCurrentlyAvailable = (bool)$isCurrentlyAvailable;
+ if ($isCurrentlyAvailable) {
+ $this->manager->revertUserStatus($userId, IUserStatus::MESSAGE_AVAILABILITY, IUserStatus::DND);
+ } else {
+ // 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->manager->setUserStatus($userId, IUserStatus::MESSAGE_AVAILABILITY, IUserStatus::DND, true);
+ }
$this->logger->debug('User status automation ran');
}