Skip to content

Commit

Permalink
fixup! enh(userstatus): add OOO automation and remove calendar automa…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
miaulalala committed Nov 27, 2023
1 parent ec7276c commit 8e4291c
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 119 deletions.
16 changes: 8 additions & 8 deletions apps/dav/lib/BackgroundJob/UserStatusAutomation.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@

class UserStatusAutomation extends TimedJob {
public function __construct(private ITimeFactory $timeFactory,
private IDBConnection $connection,
private IJobList $jobList,
private LoggerInterface $logger,
private IManager $manager,
private IConfig $config,
private IAvailabilityCoordinator $coordinator,
private IUserManager $userManager) {
private IDBConnection $connection,
private IJobList $jobList,
private LoggerInterface $logger,
private IManager $manager,
private IConfig $config,
private IAvailabilityCoordinator $coordinator,
private IUserManager $userManager) {
parent::__construct($timeFactory);

// Interval 0 might look weird, but the last_checked is always moved
Expand Down Expand Up @@ -246,7 +246,7 @@ private function processOutOfOfficeData(IUser $user, ?IOutOfOfficeData $ooo): bo
return true;
}

$this->logger->debug('User is currently in an OOO period, reverting other atomated status and setting OOO DND status');
$this->logger->debug('User is currently in an OOO period, reverting other automated status and setting OOO DND status');
// 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);
Expand Down
3 changes: 2 additions & 1 deletion apps/dav/lib/CalDAV/Status/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
namespace OCA\DAV\CalDAV\Status;

class Status {
public function __construct(private string $status = '', private ?string $message = null, private ?string $customMessage = null, private ?int $timestamp = null, private ?string $customEmoji = 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 Down
1 change: 0 additions & 1 deletion apps/dav/lib/CalDAV/Status/StatusService.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
use Sabre\VObject\Component\VEvent;
use Sabre\VObject\Parameter;
use Sabre\VObject\Property;
use Sabre\VObject\Reader;

class StatusService {
public function __construct(private ITimeFactory $timeFactory,
Expand Down
1 change: 0 additions & 1 deletion apps/dav/lib/Db/Absence.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
namespace OCA\DAV\Db;

use DateTime;
use DateTimeZone;
use Exception;
use InvalidArgumentException;
use JsonSerializable;
Expand Down
10 changes: 2 additions & 8 deletions apps/dav/lib/Listener/OutOfOfficeListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,17 @@
namespace OCA\DAV\Listener;

use DateTimeImmutable;
use OCA\DAV\BackgroundJob\UserStatusAutomation;
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CalDAV\Calendar;
use OCA\DAV\CalDAV\CalendarHome;
use OCA\DAV\ServerFactory;
use OCA\UserStatus\Service\StatusService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IConfig;
use OCP\User\Events\OutOfOfficeChangedEvent;
use OCP\User\Events\OutOfOfficeClearedEvent;
use OCP\User\Events\OutOfOfficeScheduledEvent;
use OCP\User\IOutOfOfficeData;
use OCP\UserStatus\IManager;
use OCP\UserStatus\IUserStatus;
use Psr\Log\LoggerInterface;
use Sabre\DAV\Exception\NotFound;
use Sabre\VObject\Component\VCalendar;
Expand Down Expand Up @@ -86,7 +80,7 @@ public function handle(Event $event): void {
} finally {
fclose($stream);
}
} else if ($event instanceof OutOfOfficeChangedEvent) {
} elseif ($event instanceof OutOfOfficeChangedEvent) {
$userId = $event->getData()->getUser()->getUID();
$principal = "principals/users/$userId";
$calendarNode = $this->getCalendarNode($principal, $userId);
Expand All @@ -112,7 +106,7 @@ public function handle(Event $event): void {
fclose($stream);
}
}
} else if ($event instanceof OutOfOfficeClearedEvent) {
} elseif ($event instanceof OutOfOfficeClearedEvent) {
$userId = $event->getData()->getUser()->getUID();
$principal = "principals/users/$userId";
$calendarNode = $this->getCalendarNode($principal, $userId);
Expand Down
10 changes: 2 additions & 8 deletions apps/dav/lib/Service/AbsenceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,21 @@
namespace OCA\DAV\Service;

use InvalidArgumentException;
use OC\User\OutOfOfficeData;
use OCA\DAV\BackgroundJob\OutOfOfficeEventDispatcherJob;
use OCA\DAV\CalDAV\TimezoneService;
use OC\User\OutOfOfficeData;
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CalDAV\CalendarImpl;
use OCA\DAV\Db\Absence;
use OCA\DAV\Db\AbsenceMapper;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\BackgroundJob\IJobList;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Calendar\ICalendar;
use OCP\BackgroundJob\IJobList;
use OCP\Calendar\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IUser;
use OCP\User\Events\OutOfOfficeChangedEvent;
use OCP\User\Events\OutOfOfficeClearedEvent;
use OCP\User\Events\OutOfOfficeScheduledEvent;
use Sabre\VObject\Component\VCalendar;
use Sabre\VObject\Component\VTimeZone;
use Sabre\VObject\Reader;

class AbsenceService {
public function __construct(
Expand Down
1 change: 0 additions & 1 deletion apps/dav/tests/unit/Listener/OutOfOfficeListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
use OCA\DAV\Connector\Sabre\Server;
use OCA\DAV\Listener\OutOfOfficeListener;
use OCA\DAV\ServerFactory;
use OCA\UserStatus\Service\StatusService;
use OCP\EventDispatcher\Event;
use OCP\IConfig;
use OCP\IUser;
Expand Down
Loading

0 comments on commit 8e4291c

Please sign in to comment.