Skip to content

Commit

Permalink
refactor: drop fallback for availability coordinator
Browse files Browse the repository at this point in the history
Fallback can go because Mail 4.0 requires at least Nextcloud 30.

Signed-off-by: Daniel Kesselberg <[email protected]>
  • Loading branch information
kesselb committed Oct 10, 2024
1 parent b6f3726 commit d9c4aac
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 27 deletions.
15 changes: 1 addition & 14 deletions lib/Service/OutOfOfficeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,18 @@
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IUser;
use OCP\User\IAvailabilityCoordinator;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;

class OutOfOfficeService {
private ?IAvailabilityCoordinator $availabilityCoordinator;

public function __construct(
private OutOfOfficeParser $outOfOfficeParser,
private SieveService $sieveService,
private LoggerInterface $logger,
private AliasesService $aliasesService,
private ITimeFactory $timeFactory,
ContainerInterface $container,
private IAvailabilityCoordinator $availabilityCoordinator,
) {
// TODO: inject directly if we only support Nextcloud >= 28
try {
$this->availabilityCoordinator = $container->get(IAvailabilityCoordinator::class);
} catch (ContainerExceptionInterface $e) {
$this->availabilityCoordinator = null;
}
}

/**
Expand Down Expand Up @@ -102,10 +93,6 @@ public function update(MailAccount $account, OutOfOfficeState $state): void {
* @throws InvalidArgumentException If the given mail account doesn't follow out-of-office settings
*/
public function updateFromSystem(MailAccount $mailAccount, IUser $user): ?OutOfOfficeState {
if ($this->availabilityCoordinator === null) {
throw new ServiceException('System out-of-office data is only available in Nextcloud >= 28');
}

if (!$mailAccount->getOutOfOfficeFollowsSystem()) {
throw new InvalidArgumentException('The mail account does not follow system out-of-office settings');
}
Expand Down
13 changes: 0 additions & 13 deletions tests/Unit/Service/OutOfOfficeServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,6 @@ class OutOfOfficeServiceTest extends TestCase {
protected function setUp(): void {
parent::setUp();

if (!interface_exists(IAvailabilityCoordinator::class)
|| !interface_exists(IOutOfOfficeData::class)) {
$this->markTestSkipped('Out-of-office feature is not available');
}

$this->container = $this->createMock(ContainerInterface::class);
$this->availabilityCoordinator = $this->createMock(IAvailabilityCoordinator::class);

$this->container->expects(self::once())
->method('get')
->with(IAvailabilityCoordinator::class)
->willReturn($this->availabilityCoordinator);

$this->serviceMock = $this->createServiceMock(OutOfOfficeService::class, [
'container' => $this->container,
]);
Expand Down

0 comments on commit d9c4aac

Please sign in to comment.