diff options
author | Anna Larch <anna@nextcloud.com> | 2023-09-25 14:47:02 +0200 |
---|---|---|
committer | Anna Larch <anna@nextcloud.com> | 2023-11-09 16:20:19 +0100 |
commit | f14a4f8fd73c71e76a9747ac51e657030f5bb835 (patch) | |
tree | 6d5ec8e5365a72b83bfd270ce56bcbaa06703b8a /apps/user_status/lib/Db/UserStatusMapper.php | |
parent | 1aa24c024e207b54df3867f5f7ccd67625ac0492 (diff) | |
download | nextcloud-server-f14a4f8fd73c71e76a9747ac51e657030f5bb835.tar.gz nextcloud-server-f14a4f8fd73c71e76a9747ac51e657030f5bb835.zip |
feat(user status): automate user status for events
and automatically set a user status to free or busy depending on their calendar
transparency, event status and availability settings
Signed-off-by: Anna Larch <anna@nextcloud.com>
Diffstat (limited to 'apps/user_status/lib/Db/UserStatusMapper.php')
-rw-r--r-- | apps/user_status/lib/Db/UserStatusMapper.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/apps/user_status/lib/Db/UserStatusMapper.php b/apps/user_status/lib/Db/UserStatusMapper.php index 3621c1bfa96..c8ffcca5ad9 100644 --- a/apps/user_status/lib/Db/UserStatusMapper.php +++ b/apps/user_status/lib/Db/UserStatusMapper.php @@ -26,6 +26,7 @@ declare(strict_types=1); namespace OCA\UserStatus\Db; +use Sabre\CalDAV\Schedule\Plugin; use OCP\AppFramework\Db\QBMapper; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; @@ -210,4 +211,23 @@ class UserStatusMapper extends QBMapper { $qb->executeStatement(); } + + public function getAvailabilityFromPropertiesTable(string $userId): ?string { + $propertyPath = 'calendars/' . $userId . '/inbox'; + $propertyName = '{' . Plugin::NS_CALDAV . '}calendar-availability'; + + $query = $this->db->getQueryBuilder(); + $query->select('propertyvalue') + ->from('properties') + ->where($query->expr()->eq('userid', $query->createNamedParameter($userId))) + ->andWhere($query->expr()->eq('propertypath', $query->createNamedParameter($propertyPath))) + ->andWhere($query->expr()->eq('propertyname', $query->createNamedParameter($propertyName))) + ->setMaxResults(1); + + $result = $query->executeQuery(); + $property = $result->fetchOne(); + $result->closeCursor(); + + return ($property === false ? null : $property); + } } |