1
0
Fork 0
mirror of synced 2024-06-29 19:50:26 +12:00

refactor based on review

This commit is contained in:
Damodar Lohani 2021-05-12 11:04:48 +05:45
parent be5b882fe7
commit 0e90c75a12

View file

@ -14,8 +14,6 @@ use Appwrite\Database\Database;
use Appwrite\Database\Document; use Appwrite\Database\Document;
use Appwrite\Database\Validator\Authorization; use Appwrite\Database\Validator\Authorization;
use Appwrite\Network\Validator\Origin; use Appwrite\Network\Validator\Origin;
use Utopia\Storage\Device\Local;
use Utopia\Storage\Storage;
use Appwrite\Utopia\Response\Filters\V06; use Appwrite\Utopia\Response\Filters\V06;
use Utopia\CLI\Console; use Utopia\CLI\Console;
@ -35,12 +33,12 @@ App::init(function ($utopia, $request, $response, $console, $project, $consoleDB
/** @var array $clients */ /** @var array $clients */
$domain = $request->getHostname(); $domain = $request->getHostname();
$checkedDomains = Config::getParam('checkedDomains', []); $domains = Config::getParam('domains', []);
if (!array_key_exists($domain, $checkedDomains)) { if (!array_key_exists($domain, $domains)) {
$domain = new Domain(!empty($domain) ? $domain : ''); $domain = new Domain(!empty($domain) ? $domain : '');
if (empty($domain->get()) || !$domain->isKnown() || $domain->isTest()) { if (empty($domain->get()) || !$domain->isKnown() || $domain->isTest()) {
$checkedDomains[$domain->get()] = false; $domains[$domain->get()] = false;
Console::warning($domain->get() . ' is not a publicly accessible domain. Skipping SSL certificate generation.'); Console::warning($domain->get() . ' is not a publicly accessible domain. Skipping SSL certificate generation.');
} else { } else {
Authorization::disable(); Authorization::disable();
@ -65,22 +63,21 @@ App::init(function ($utopia, $request, $response, $console, $project, $consoleDB
$dbDomain = $consoleDB->createDocument($dbDomain); $dbDomain = $consoleDB->createDocument($dbDomain);
Authorization::enable(); Authorization::enable();
Console::info('Issuing a TLS certificate for the master domain (' . $domain->get() . ') in ~30 seconds. Console::info('Issuing a TLS certificate for the master domain (' . $domain->get() . ') in ~30 seconds..'); // TODO move this to installation script
.'); // TODO move this to installation script
ResqueScheduler::enqueueAt(\time() + 30, 'v1-certificates', 'CertificatesV1', [ ResqueScheduler::enqueueAt(\time() + 30, 'v1-certificates', 'CertificatesV1', [
'document' => [], 'document' => $dbDomain,
'domain' => $domain->get(), 'domain' => $domain->get(),
'validateTarget' => false, 'validateTarget' => false,
'validateCNAME' => false, 'validateCNAME' => false,
]); ]);
} }
$checkedDomains[$domain->get()] = true; $domains[$domain->get()] = true;
} }
Console::info('adding ' . $domain->get() . ' to list of domains already checked'); Console::info('adding ' . $domain->get() . ' to list of domains already checked');
Config::setParam('checkedDomains', $checkedDomains); Config::setParam('domains', $domains);
} }
$localeParam = (string)$request->getParam('locale', $request->getHeader('x-appwrite-locale', '')); $localeParam = (string)$request->getParam('locale', $request->getHeader('x-appwrite-locale', ''));