Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/dav/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
'OCA\\DAV\\BackgroundJob\\RegisterRegenerateBirthdayCalendars' => $baseDir . '/../lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php',
'OCA\\DAV\\BackgroundJob\\UpdateCalendarResourcesRoomsBackgroundJob' => $baseDir . '/../lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php',
'OCA\\DAV\\BackgroundJob\\UploadCleanup' => $baseDir . '/../lib/BackgroundJob/UploadCleanup.php',
'OCA\\DAV\\BackgroundJob\\UserStatusAutomation' => $baseDir . '/../lib/BackgroundJob/UserStatusAutomation.php',
'OCA\\DAV\\BulkUpload\\BulkUploadPlugin' => $baseDir . '/../lib/BulkUpload/BulkUploadPlugin.php',
'OCA\\DAV\\BulkUpload\\MultipartRequestParser' => $baseDir . '/../lib/BulkUpload/MultipartRequestParser.php',
'OCA\\DAV\\CalDAV\\Activity\\Backend' => $baseDir . '/../lib/CalDAV/Activity/Backend.php',
Expand Down
1 change: 0 additions & 1 deletion apps/dav/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class ComposerStaticInitDAV
'OCA\\DAV\\BackgroundJob\\RegisterRegenerateBirthdayCalendars' => __DIR__ . '/..' . '/../lib/BackgroundJob/RegisterRegenerateBirthdayCalendars.php',
'OCA\\DAV\\BackgroundJob\\UpdateCalendarResourcesRoomsBackgroundJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJob.php',
'OCA\\DAV\\BackgroundJob\\UploadCleanup' => __DIR__ . '/..' . '/../lib/BackgroundJob/UploadCleanup.php',
'OCA\\DAV\\BackgroundJob\\UserStatusAutomation' => __DIR__ . '/..' . '/../lib/BackgroundJob/UserStatusAutomation.php',
'OCA\\DAV\\BulkUpload\\BulkUploadPlugin' => __DIR__ . '/..' . '/../lib/BulkUpload/BulkUploadPlugin.php',
'OCA\\DAV\\BulkUpload\\MultipartRequestParser' => __DIR__ . '/..' . '/../lib/BulkUpload/MultipartRequestParser.php',
'OCA\\DAV\\CalDAV\\Activity\\Backend' => __DIR__ . '/..' . '/../lib/CalDAV/Activity/Backend.php',
Expand Down
6 changes: 0 additions & 6 deletions apps/dav/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
use OCA\DAV\Listener\ClearPhotoCacheListener;
use OCA\DAV\Listener\SubscriptionListener;
use OCA\DAV\Listener\TrustedServerRemovedListener;
use OCA\DAV\Listener\UserPreferenceListener;
use OCA\DAV\Search\ContactsSearchProvider;
use OCA\DAV\Search\EventsSearchProvider;
use OCA\DAV\Search\TasksSearchProvider;
Expand All @@ -99,8 +98,6 @@
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\IAppContainer;
use OCP\Calendar\IManager as ICalendarManager;
use OCP\Config\BeforePreferenceDeletedEvent;
use OCP\Config\BeforePreferenceSetEvent;
use OCP\Contacts\IManager as IContactsManager;
use OCP\Files\AppData\IAppDataFactory;
use OCP\IUser;
Expand Down Expand Up @@ -196,9 +193,6 @@ public function register(IRegistrationContext $context): void {
$context->registerEventListener(CardUpdatedEvent::class, ClearPhotoCacheListener::class);
$context->registerEventListener(TrustedServerRemovedEvent::class, TrustedServerRemovedListener::class);

$context->registerEventListener(BeforePreferenceDeletedEvent::class, UserPreferenceListener::class);
$context->registerEventListener(BeforePreferenceSetEvent::class, UserPreferenceListener::class);

$context->registerEventListener(OutOfOfficeChangedEvent::class, OutOfOfficeListener::class);
$context->registerEventListener(OutOfOfficeClearedEvent::class, OutOfOfficeListener::class);
$context->registerEventListener(OutOfOfficeScheduledEvent::class, OutOfOfficeListener::class);
Expand Down
204 changes: 0 additions & 204 deletions apps/dav/lib/BackgroundJob/UserStatusAutomation.php

This file was deleted.

17 changes: 15 additions & 2 deletions apps/dav/lib/CalDAV/Status/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
namespace OCA\DAV\CalDAV\Status;

class Status {

public function __construct(private string $status = '', private ?string $message = null, private ?string $customMessage = null){}
public function __construct(private string $status = '', private ?string $message = null, private ?string $customMessage = null, private ?int $timestamp = null, private ?string $customEmoji = null){}

public function getStatus(): string {
return $this->status;
Expand All @@ -53,5 +52,19 @@ public function setCustomMessage(?string $customMessage): void {
$this->customMessage = $customMessage;
}

public function setEndTime(?int $timestamp): void {
$this->timestamp = $timestamp;
}

public function getEndTime(): ?int {
return $this->timestamp;
}

public function getCustomEmoji(): ?string {
return $this->customEmoji;
}

public function setCustomEmoji(?string $emoji): void {
$this->customEmoji = $emoji;
}
}
11 changes: 8 additions & 3 deletions apps/dav/lib/CalDAV/Status/StatusService.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,16 @@ public function processCalendarAvailability(User $user, ?string $availability):
// If there is no FreeBusy property, the time-range is empty and available
// so set the status to online as otherwise we will never recover from a BUSY status
if (count($freeBusyProperties) === 0) {
return new Status(IUserStatus::ONLINE);
return new Status(IUserStatus::ONLINE, IUserStatus::ONLINE);
}

/** @var Property $freeBusyProperty */
$freeBusyProperty = $freeBusyProperties[0];
if (!$freeBusyProperty->offsetExists('FBTYPE')) {
// If there is no FBTYPE, it means it's busy from a regular event
return new Status(IUserStatus::BUSY, IUserStatus::MESSAGE_CALENDAR_BUSY);
$status = new Status(IUserStatus::BUSY, IUserStatus::MESSAGE_CALENDAR_BUSY);
$status->setCustomEmoji(IUserStatus::MEETING_ICON);
return $status;
}

// If we can't deal with the FBTYPE (custom properties are a possibility)
Expand All @@ -224,8 +226,11 @@ public function processCalendarAvailability(User $user, ?string $availability):
$fbType = $fbTypeParameter->getValue();
switch ($fbType) {
case 'BUSY':
return new Status(IUserStatus::BUSY, IUserStatus::MESSAGE_CALENDAR_BUSY, $this->l10n->t('In a meeting'));
$status = new Status(IUserStatus::BUSY, IUserStatus::MESSAGE_CALENDAR_BUSY, $this->l10n->t('In a meeting'));
$status->setCustomEmoji(IUserStatus::MEETING_ICON);
return $status;
case 'BUSY-UNAVAILABLE':
// @todo - the user could also have set the option to set a DND status
return new Status(IUserStatus::AWAY, IUserStatus::MESSAGE_AVAILABILITY);
case 'BUSY-TENTATIVE':
return new Status(IUserStatus::AWAY, IUserStatus::MESSAGE_CALENDAR_BUSY_TENTATIVE);
Expand Down
4 changes: 4 additions & 0 deletions apps/dav/lib/Controller/AvailabilitySettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\Response;
use OCP\IRequest;
use OCP\User\IAvailabilityCoordinator;

class AvailabilitySettingsController extends Controller {
public function __construct(
IRequest $request,
private ?string $userId,
private AbsenceService $absenceService,
private IAvailabilityCoordinator $coordinator,
) {
parent::__construct(Application::APP_ID, $request);
}
Expand Down Expand Up @@ -74,6 +76,7 @@ public function updateAbsence(
$status,
$message,
);
$this->coordinator->clearCache($userId);
return new JSONResponse($absence);
}

Expand All @@ -88,6 +91,7 @@ public function clearAbsence(): Response {
}

$this->absenceService->clearAbsence($userId);
$this->coordinator->clearCache($userId);
return new JSONResponse([]);
}

Expand Down
8 changes: 5 additions & 3 deletions apps/dav/lib/Db/Absence.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,18 @@ public function __construct() {
$this->addType('message', 'string');
}

public function toOutOufOfficeData(IUser $user): IOutOfOfficeData {
public function toOutOufOfficeData(IUser $user, ?string $timezone): IOutOfOfficeData {
if ($user->getUID() !== $this->getUserId()) {
throw new InvalidArgumentException("The user doesn't match the user id of this absence! Expected " . $this->getUserId() . ", got " . $user->getUID());
}
if ($this->getId() === null) {
throw new Exception('Creating out-of-office data without ID');
}

$startDate = new DateTimeImmutable($this->getFirstDay());
$endDate = new DateTimeImmutable($this->getLastDay());
$tz = new \DateTimeZone($timezone ?? 'UTC');
$startDate = new \DateTime($this->getFirstDay(), $tz);
$endDate = new \DateTime($this->getLastDay(), $tz);
$endDate->setTime(23, 59);
return new OutOfOfficeData(
(string)$this->getId(),
$user,
Expand Down
20 changes: 20 additions & 0 deletions apps/dav/lib/Db/AbsenceMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use OCP\AppFramework\Db\QBMapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use Sabre\CalDAV\Schedule\Plugin;

/**
* @template-extends QBMapper<Absence>
Expand Down Expand Up @@ -78,4 +79,23 @@ public function deleteByUserId(string $userId): void {
);
$qb->executeStatement();
}

public function getAvailability(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);
}
}
Loading