Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7398374f authored by Ronak Patel's avatar Ronak Patel
Browse files

removed background job and update domains code

parent 4788399c
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@
    <description><![CDATA[in /e/OS cloud, nextcloud accounts are linked to mail accounts. This app ensures both are coordinated: it sets the e-mail address, quota and storage of the user upon creation.
    It also completes the account deletion by cleaning other parts of the /e/OS cloud setup to ensure no more data is retained when a user requests an account deletion.
    This app uses the UserDeletedEvent to invoke scripts in the docker-welcome container of /e/OS cloud setup]]></description>
    <version>6.0.3</version>
    <version>6.0.4</version>
    <licence>agpl</licence>
    <author mail="dev@murena.com" homepage="https://murena.com/">Murena SAS</author>
    <namespace>EcloudAccounts</namespace>
+0 −35
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace OCA\EcloudAccounts\BackgroundJob;

use OCA\EcloudAccounts\Service\UserService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use Psr\Log\LoggerInterface;

class BlacklistedDomainsJob extends TimedJob {
	private LoggerInterface $logger;
	private UserService $userService;
	private ITimeFactory $timeFactory;
	public const INTERVAL_PERIOD = 7 * 24 * 60 * 60;// Run for 7 days
	public function __construct(LoggerInterface $logger, ITimeFactory $timeFactory, UserService $userService) {
		parent::__construct($timeFactory);

		$this->setInterval(self::INTERVAL_PERIOD);
		$this->setTimeSensitivity(self::TIME_INSENSITIVE);
		$this->timeFactory = $timeFactory;
		$this->userService = $userService;
		$this->logger = $logger;
	}

	protected function run($argument): void {
		try {
			$this->userService->updateBlacklistedDomains();
		} catch (\Exception $e) {
			$this->logger->logException('Error updating blacklisted domains for account creation', ['exception' => $e]);
			return;
		}
	}
}
+0 −30
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace OCA\EcloudAccounts\Command;

use OCA\EcloudAccounts\AppInfo\Application;
use OCA\EcloudAccounts\Service\UserService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class UpdateBlacklistedDomains extends Command {
	private UserService $userService;

	public function __construct(UserService $userService) {
		parent::__construct();
		$this->userService = $userService;
	}

	protected function configure() {
		$this->setName(Application::APP_ID.':update-blacklisted-domains')->setDescription('Update blacklisted domains');
	}

	protected function execute(InputInterface $input, OutputInterface $output): int {
		$this->userService->updateBlacklistedDomains();
		$output->writeln('Updated blacklisted domains for creation.');
		return 1;
	}
}
+0 −5
Original line number Diff line number Diff line
@@ -585,9 +585,4 @@ class UserService {
	private function getDefaultQuota() {
		return $this->config->getSystemValueInt('default_quota_in_megabytes', 1024);
	}
	public function updateBlacklistedDomains() {
		$blacklisted_domain_url = 'https://raw.githubusercontent.com/disposable/disposable-email-domains/master/domains.json';
		$json_data = file_get_contents($blacklisted_domain_url);
		$this->config->setAppValue(Application::APP_ID, 'blacklisted_domains', $json_data);
	}
}