migrate therinaldos.com data
Build & Deploy to DigitalOcean Space / build (push) Failing after 2m38s

This commit is contained in:
2024-05-05 15:50:45 -04:00
commit ef1ff240d4
23182 changed files with 3801898 additions and 0 deletions
@@ -0,0 +1,64 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Björn Schießle <bjoern@schiessle.org>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCA\DAV\Command;
use OCA\DAV\CardDAV\CardDavBackend;
use OCP\IUserManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class CreateAddressBook extends Command {
public function __construct(
private IUserManager $userManager,
private CardDavBackend $cardDavBackend,
) {
parent::__construct();
}
protected function configure(): void {
$this
->setName('dav:create-addressbook')
->setDescription('Create a dav addressbook')
->addArgument('user',
InputArgument::REQUIRED,
'User for whom the addressbook will be created')
->addArgument('name',
InputArgument::REQUIRED,
'Name of the addressbook');
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$user = $input->getArgument('user');
if (!$this->userManager->userExists($user)) {
throw new \InvalidArgumentException("User <$user> in unknown.");
}
$name = $input->getArgument('name');
$this->cardDavBackend->createAddressBook("principals/users/$user", $name, []);
return self::SUCCESS;
}
}
@@ -0,0 +1,101 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Joas Schilling <coding@schilljs.com>
* @author Thomas Citharel <nextcloud@tcit.fr>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCA\DAV\Command;
use OC\KnownUser\KnownUserService;
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CalDAV\Proxy\ProxyMapper;
use OCA\DAV\Connector\Sabre\Principal;
use OCP\Accounts\IAccountManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IGroupManager;
use OCP\IUserManager;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class CreateCalendar extends Command {
public function __construct(
protected IUserManager $userManager,
private IGroupManager $groupManager,
protected IDBConnection $dbConnection,
) {
parent::__construct();
}
protected function configure(): void {
$this
->setName('dav:create-calendar')
->setDescription('Create a dav calendar')
->addArgument('user',
InputArgument::REQUIRED,
'User for whom the calendar will be created')
->addArgument('name',
InputArgument::REQUIRED,
'Name of the calendar');
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$user = $input->getArgument('user');
if (!$this->userManager->userExists($user)) {
throw new \InvalidArgumentException("User <$user> in unknown.");
}
$principalBackend = new Principal(
$this->userManager,
$this->groupManager,
\OC::$server->get(IAccountManager::class),
\OC::$server->getShareManager(),
\OC::$server->getUserSession(),
\OC::$server->getAppManager(),
\OC::$server->query(ProxyMapper::class),
\OC::$server->get(KnownUserService::class),
\OC::$server->getConfig(),
\OC::$server->getL10NFactory(),
);
$random = \OC::$server->getSecureRandom();
$logger = \OC::$server->get(LoggerInterface::class);
$dispatcher = \OC::$server->get(IEventDispatcher::class);
$config = \OC::$server->get(IConfig::class);
$name = $input->getArgument('name');
$caldav = new CalDavBackend(
$this->dbConnection,
$principalBackend,
$this->userManager,
$this->groupManager,
$random,
$logger,
$dispatcher,
$config
);
$caldav->createCalendar("principals/users/$user", $name, []);
return self::SUCCESS;
}
}
@@ -0,0 +1,119 @@
<?php
declare(strict_types=1);
/**
*
* @copyright Copyright (c) 2021, Mattia Narducci (mattianarducci1@gmail.com)
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Command;
use OCA\DAV\CalDAV\BirthdayService;
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CalDAV\Calendar;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IUserManager;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class DeleteCalendar extends Command {
public function __construct(
private CalDavBackend $calDav,
private IConfig $config,
private IL10N $l10n,
private IUserManager $userManager,
private LoggerInterface $logger,
) {
parent::__construct();
}
protected function configure(): void {
$this
->setName('dav:delete-calendar')
->setDescription('Delete a dav calendar')
->addArgument('uid',
InputArgument::REQUIRED,
'User who owns the calendar')
->addArgument('name',
InputArgument::OPTIONAL,
'Name of the calendar to delete')
->addOption('birthday',
null,
InputOption::VALUE_NONE,
'Delete the birthday calendar')
->addOption('force',
'f',
InputOption::VALUE_NONE,
'Force delete skipping trashbin');
}
protected function execute(
InputInterface $input,
OutputInterface $output
): int {
/** @var string $user **/
$user = $input->getArgument('uid');
if (!$this->userManager->userExists($user)) {
throw new \InvalidArgumentException(
'User <' . $user . '> is unknown.');
}
$birthday = $input->getOption('birthday');
if ($birthday !== false) {
$name = BirthdayService::BIRTHDAY_CALENDAR_URI;
} else {
/** @var string $name **/
$name = $input->getArgument('name');
if (!$name) {
throw new \InvalidArgumentException(
'Please specify a calendar name or --birthday');
}
}
$calendarInfo = $this->calDav->getCalendarByUri(
'principals/users/' . $user,
$name);
if ($calendarInfo === null) {
throw new \InvalidArgumentException(
'User <' . $user . '> has no calendar named <' . $name . '>. You can run occ dav:list-calendars to list calendars URIs for this user.');
}
$calendar = new Calendar(
$this->calDav,
$calendarInfo,
$this->l10n,
$this->config,
$this->logger
);
$force = $input->getOption('force');
if ($force) {
$calendar->disableTrashbin();
}
$calendar->delete();
return self::SUCCESS;
}
}
@@ -0,0 +1,95 @@
<?php
/**
* @copyright Copyright (c) 2018, Georg Ehrke
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Joas Schilling <coding@schilljs.com>
* @author Thomas Citharel <nextcloud@tcit.fr>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Command;
use OCA\DAV\CalDAV\BirthdayService;
use OCA\DAV\CalDAV\CalDavBackend;
use OCP\IUserManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ListCalendars extends Command {
public function __construct(
protected IUserManager $userManager,
private CalDavBackend $caldav,
) {
parent::__construct();
}
protected function configure(): void {
$this
->setName('dav:list-calendars')
->setDescription('List all calendars of a user')
->addArgument('uid',
InputArgument::REQUIRED,
'User for whom all calendars will be listed');
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$user = $input->getArgument('uid');
if (!$this->userManager->userExists($user)) {
throw new \InvalidArgumentException("User <$user> is unknown.");
}
$calendars = $this->caldav->getCalendarsForUser("principals/users/$user");
$calendarTableData = [];
foreach ($calendars as $calendar) {
// skip birthday calendar
if ($calendar['uri'] === BirthdayService::BIRTHDAY_CALENDAR_URI) {
continue;
}
$readOnly = false;
$readOnlyIndex = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only';
if (isset($calendar[$readOnlyIndex])) {
$readOnly = $calendar[$readOnlyIndex];
}
$calendarTableData[] = [
$calendar['uri'],
$calendar['{DAV:}displayname'],
$calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'],
$calendar['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname'],
$readOnly ? ' x ' : ' ✓ ',
];
}
if (count($calendarTableData) > 0) {
$table = new Table($output);
$table->setHeaders(['uri', 'displayname', 'owner\'s userid', 'owner\'s displayname', 'writable'])
->setRows($calendarTableData);
$table->render();
} else {
$output->writeln("<info>User <$user> has no calendars</info>");
}
return self::SUCCESS;
}
}
@@ -0,0 +1,197 @@
<?php
/**
* @copyright Copyright (c) 2016 Thomas Citharel <nextcloud@tcit.fr>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Joas Schilling <coding@schilljs.com>
* @author John Molakvoæ <skjnldsv@protonmail.com>
* @author Thomas Citharel <nextcloud@tcit.fr>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Command;
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CalDAV\Calendar;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IUserManager;
use OCP\Share\IManager as IShareManager;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
class MoveCalendar extends Command {
private ?SymfonyStyle $io = null;
public const URI_USERS = 'principals/users/';
public function __construct(
private IUserManager $userManager,
private IGroupManager $groupManager,
private IShareManager $shareManager,
private IConfig $config,
private IL10N $l10n,
private CalDavBackend $calDav,
private LoggerInterface $logger,
) {
parent::__construct();
}
protected function configure(): void {
$this
->setName('dav:move-calendar')
->setDescription('Move a calendar from an user to another')
->addArgument('name',
InputArgument::REQUIRED,
'Name of the calendar to move')
->addArgument('sourceuid',
InputArgument::REQUIRED,
'User who currently owns the calendar')
->addArgument('destinationuid',
InputArgument::REQUIRED,
'User who will receive the calendar')
->addOption('force', 'f', InputOption::VALUE_NONE, "Force the migration by removing existing shares and renaming calendars in case of conflicts");
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$userOrigin = $input->getArgument('sourceuid');
$userDestination = $input->getArgument('destinationuid');
$this->io = new SymfonyStyle($input, $output);
if (!$this->userManager->userExists($userOrigin)) {
throw new \InvalidArgumentException("User <$userOrigin> is unknown.");
}
if (!$this->userManager->userExists($userDestination)) {
throw new \InvalidArgumentException("User <$userDestination> is unknown.");
}
$name = $input->getArgument('name');
$newName = null;
$calendar = $this->calDav->getCalendarByUri(self::URI_USERS . $userOrigin, $name);
if (null === $calendar) {
throw new \InvalidArgumentException("User <$userOrigin> has no calendar named <$name>. You can run occ dav:list-calendars to list calendars URIs for this user.");
}
// Calendar already exists
if ($this->calendarExists($userDestination, $name)) {
if ($input->getOption('force')) {
// Try to find a suitable name
$newName = $this->getNewCalendarName($userDestination, $name);
// If we didn't find a suitable value after all the iterations, give up
if ($this->calendarExists($userDestination, $newName)) {
throw new \InvalidArgumentException("Unable to find a suitable calendar name for <$userDestination> with initial name <$name>.");
}
} else {
throw new \InvalidArgumentException("User <$userDestination> already has a calendar named <$name>.");
}
}
$hadShares = $this->checkShares($calendar, $userOrigin, $userDestination, $input->getOption('force'));
if ($hadShares) {
/**
* Warn that share links have changed if there are shares
*/
$this->io->note([
"Please note that moving calendar " . $calendar['uri'] . " from user <$userOrigin> to <$userDestination> has caused share links to change.",
"Sharees will need to change \"example.com/remote.php/dav/calendars/uid/" . $calendar['uri'] . "_shared_by_$userOrigin\" to \"example.com/remote.php/dav/calendars/uid/" . $newName ?: $calendar['uri'] . "_shared_by_$userDestination\""
]);
}
$this->calDav->moveCalendar($name, self::URI_USERS . $userOrigin, self::URI_USERS . $userDestination, $newName);
$this->io->success("Calendar <$name> was moved from user <$userOrigin> to <$userDestination>" . ($newName ? " as <$newName>" : ''));
return self::SUCCESS;
}
/**
* Check if the calendar exists for user
*/
protected function calendarExists(string $userDestination, string $name): bool {
return null !== $this->calDav->getCalendarByUri(self::URI_USERS . $userDestination, $name);
}
/**
* Try to find a suitable new calendar name that
* doesn't exist for the provided user
*/
protected function getNewCalendarName(string $userDestination, string $name): string {
$increment = 1;
$newName = $name . '-' . $increment;
while ($increment <= 10) {
$this->io->writeln("Trying calendar name <$newName>", OutputInterface::VERBOSITY_VERBOSE);
if (!$this->calendarExists($userDestination, $newName)) {
// New name is good to go
$this->io->writeln("Found proper new calendar name <$newName>", OutputInterface::VERBOSITY_VERBOSE);
break;
}
$newName = $name . '-' . $increment;
$increment++;
}
return $newName;
}
/**
* Check that moving the calendar won't break shares
*
* @return bool had any shares or not
* @throws \InvalidArgumentException
*/
private function checkShares(array $calendar, string $userOrigin, string $userDestination, bool $force = false): bool {
$shares = $this->calDav->getShares($calendar['id']);
foreach ($shares as $share) {
[, $prefix, $userOrGroup] = explode('/', $share['href'], 3);
/**
* Check that user destination is member of the groups which whom the calendar was shared
* If we ask to force the migration, the share with the group is dropped
*/
if ($this->shareManager->shareWithGroupMembersOnly() === true && 'groups' === $prefix && !$this->groupManager->isInGroup($userDestination, $userOrGroup)) {
if ($force) {
$this->calDav->updateShares(new Calendar($this->calDav, $calendar, $this->l10n, $this->config, $this->logger), [], ['principal:principals/groups/' . $userOrGroup]);
} else {
throw new \InvalidArgumentException("User <$userDestination> is not part of the group <$userOrGroup> with whom the calendar <" . $calendar['uri'] . "> was shared. You may use -f to move the calendar while deleting this share.");
}
}
/**
* Check that calendar isn't already shared with user destination
*/
if ($userOrGroup === $userDestination) {
if ($force) {
$this->calDav->updateShares(new Calendar($this->calDav, $calendar, $this->l10n, $this->config, $this->logger), [], ['principal:principals/users/' . $userOrGroup]);
} else {
throw new \InvalidArgumentException("The calendar <" . $calendar['uri'] . "> is already shared to user <$userDestination>.You may use -f to move the calendar while deleting this share.");
}
}
}
return count($shares) > 0;
}
}
@@ -0,0 +1,80 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2018, ownCloud GmbH
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCA\DAV\Command;
use OCA\DAV\Connector\Sabre\Principal;
use OCP\IDBConnection;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Class RemoveInvalidShares - removes shared calendars and addressbook which
* have no matching principal. Happened because of a bug in the calendar app.
*/
class RemoveInvalidShares extends Command {
public function __construct(
private IDBConnection $connection,
private Principal $principalBackend,
) {
parent::__construct();
}
protected function configure(): void {
$this
->setName('dav:remove-invalid-shares')
->setDescription('Remove invalid dav shares');
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$query = $this->connection->getQueryBuilder();
$result = $query->selectDistinct('principaluri')
->from('dav_shares')
->execute();
while ($row = $result->fetch()) {
$principaluri = $row['principaluri'];
$p = $this->principalBackend->getPrincipalByPath($principaluri);
if ($p === null) {
$this->deleteSharesForPrincipal($principaluri);
}
}
$result->closeCursor();
return self::SUCCESS;
}
/**
* @param string $principaluri
*/
private function deleteSharesForPrincipal($principaluri): void {
$delete = $this->connection->getQueryBuilder();
$delete->delete('dav_shares')
->where($delete->expr()->eq('principaluri', $delete->createNamedParameter($principaluri)));
$delete->execute();
}
}
@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
/**
* @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Command;
use OCA\DAV\CalDAV\RetentionService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class RetentionCleanupCommand extends Command {
public function __construct(
private RetentionService $service,
) {
parent::__construct('dav:retention:clean-up');
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$this->service->cleanUp();
return self::SUCCESS;
}
}
@@ -0,0 +1,70 @@
<?php
/**
* @copyright Copyright (c) 2019, Georg Ehrke
*
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\DAV\Command;
use OCA\DAV\CalDAV\Reminder\ReminderService;
use OCP\IConfig;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Class SendEventReminders
*
* @package OCA\DAV\Command
*/
class SendEventReminders extends Command {
public function __construct(
protected ReminderService $reminderService,
protected IConfig $config,
) {
parent::__construct();
}
/**
* @inheritDoc
*/
protected function configure():void {
$this
->setName('dav:send-event-reminders')
->setDescription('Sends event reminders');
}
protected function execute(InputInterface $input, OutputInterface $output): int {
if ($this->config->getAppValue('dav', 'sendEventReminders', 'yes') !== 'yes') {
$output->writeln('<error>Sending event reminders disabled!</error>');
$output->writeln('<info>Please run "php occ config:app:set dav sendEventReminders --value yes"');
return self::FAILURE;
}
if ($this->config->getAppValue('dav', 'sendEventRemindersMode', 'backgroundjob') !== 'occ') {
$output->writeln('<error>Sending event reminders mode set to background-job!</error>');
$output->writeln('<info>Please run "php occ config:app:set dav sendEventRemindersMode --value occ"');
return self::FAILURE;
}
$this->reminderService->processReminders();
return self::SUCCESS;
}
}
@@ -0,0 +1,103 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
* @author Joas Schilling <coding@schilljs.com>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCA\DAV\Command;
use OCA\DAV\CalDAV\BirthdayService;
use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class SyncBirthdayCalendar extends Command {
public function __construct(
private IUserManager $userManager,
private IConfig $config,
private BirthdayService $birthdayService,
) {
parent::__construct();
}
protected function configure(): void {
$this
->setName('dav:sync-birthday-calendar')
->setDescription('Synchronizes the birthday calendar')
->addArgument('user',
InputArgument::OPTIONAL,
'User for whom the birthday calendar will be synchronized');
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$this->verifyEnabled();
$user = $input->getArgument('user');
if (!is_null($user)) {
if (!$this->userManager->userExists($user)) {
throw new \InvalidArgumentException("User <$user> in unknown.");
}
// re-enable the birthday calendar in case it's called directly with a user name
$isEnabled = $this->config->getUserValue($user, 'dav', 'generateBirthdayCalendar', 'yes');
if ($isEnabled !== 'yes') {
$this->config->setUserValue($user, 'dav', 'generateBirthdayCalendar', 'yes');
$output->writeln("Re-enabling birthday calendar for $user");
}
$output->writeln("Start birthday calendar sync for $user");
$this->birthdayService->syncUser($user);
return self::SUCCESS;
}
$output->writeln("Start birthday calendar sync for all users ...");
$p = new ProgressBar($output);
$p->start();
$this->userManager->callForSeenUsers(function ($user) use ($p) {
$p->advance();
$userId = $user->getUID();
$isEnabled = $this->config->getUserValue($userId, 'dav', 'generateBirthdayCalendar', 'yes');
if ($isEnabled !== 'yes') {
return;
}
/** @var IUser $user */
$this->birthdayService->syncUser($user->getUID());
});
$p->finish();
$output->writeln('');
return self::SUCCESS;
}
protected function verifyEnabled(): void {
$isEnabled = $this->config->getAppValue('dav', 'generateBirthdayCalendar', 'yes');
if ($isEnabled !== 'yes') {
throw new \InvalidArgumentException('Birthday calendars are disabled');
}
}
}
@@ -0,0 +1,60 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCA\DAV\Command;
use OCA\DAV\CardDAV\SyncService;
use OCP\IConfig;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class SyncSystemAddressBook extends Command {
public function __construct(
private SyncService $syncService,
private IConfig $config,
) {
parent::__construct();
}
protected function configure(): void {
$this
->setName('dav:sync-system-addressbook')
->setDescription('Synchronizes users to the system addressbook');
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$output->writeln('Syncing users ...');
$progress = new ProgressBar($output);
$progress->start();
$this->syncService->syncInstance(function () use ($progress) {
$progress->advance();
});
$progress->finish();
$output->writeln('');
$this->config->setAppValue('dav', 'needs_system_address_book_sync', 'no');
return self::SUCCESS;
}
}