This commit is contained in:
shimon 2024-09-18 11:52:59 +03:00
parent b706571a21
commit ec02d881c9
11 changed files with 12 additions and 10 deletions

View file

@ -60,7 +60,9 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo
var_dump(System::getEnv('_APP_DOMAIN_FUNCTIONS', ''));
var_dump($host);
var_dump(APP_HOSTNAME_INTERNAL);
var_dump($request->getHeader('host'));
var_dump($request->getHeader('x-forwarded-host'));
if ($route === null) {
if ($host === System::getEnv('_APP_DOMAIN_FUNCTIONS', '')) {
throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, 'This domain cannot be used for security reasons. Please use any subdomain instead.');

View file

@ -115,7 +115,7 @@ class Build extends Event
$client = new Client($this->queue, $this->connection);
return $client->enqueue([
'sourceRegion' => System::getEnv('_APP_REGION', 'default'),
'sourceRegion' => $this->getSourceRegion(),
'project' => $this->project,
'resource' => $this->resource,
'deployment' => $this->deployment,

View file

@ -77,7 +77,7 @@ class Certificate extends Event
$client = new Client($this->queue, $this->connection);
return $client->enqueue([
'sourceRegion' => System::getEnv('_APP_REGION', 'default'),
'sourceRegion' => $this->getSourceRegion(),
'project' => $this->project,
'domain' => $this->domain,
'skipRenewCheck' => $this->skipRenewCheck

View file

@ -109,7 +109,6 @@ class Database extends Event
public function trigger(): string|bool
{
try {
$dsn = new DSN($this->getProject()->getAttribute('database'));
} catch (\InvalidArgumentException) {
@ -123,7 +122,7 @@ class Database extends Event
try {
$result = $client->enqueue([
'sourceRegion' => System::getEnv('_APP_REGION', 'default'),
'sourceRegion' => $this->getSourceRegion(),
'project' => $this->project,
'user' => $this->user,
'type' => $this->type,

View file

@ -110,6 +110,8 @@ class Event
return $this->event;
}
public function getSourceRegion(): string
{
return System::getEnv('_APP_REGION', 'default');

View file

@ -220,6 +220,7 @@ class Func extends Event
$events = $this->getEvent() ? Event::generateEvents($this->getEvent(), $this->getParams()) : null;
return $client->enqueue([
'sourceRegion' => $this->getSourceRegion(),
'project' => $this->project,
'user' => $this->user,
'function' => $this->function,

View file

@ -80,7 +80,6 @@ class Migration extends Event
return $client->enqueue([
'sourceRegion' => $this->getSourceRegion(),
'project' => $this->project,
'user' => $this->user,
'migration' => $this->migration

View file

@ -90,8 +90,8 @@ class Builds extends Action
$resource = new Document($payload['resource'] ?? []);
$deployment = new Document($payload['deployment'] ?? []);
$template = new Document($payload['template'] ?? []);
$this->sourceRegion = $payload['sourceRegion'] ?? 'default';
$log->addTag('projectId', $project->getId());
$log->addTag('type', $type);

View file

@ -80,8 +80,8 @@ class Certificates extends Action
$document = new Document($payload['domain'] ?? []);
$domain = new Domain($document->getAttribute('domain', ''));
$skipRenewCheck = $payload['skipRenewCheck'] ?? false;
$this->sourceRegion = $payload['sourceRegion'] ?? 'default';
$log->addTag('domain', $domain->get());
$this->execute($domain, $dbForConsole, $queueForMails, $queueForEvents, $queueForFunctions, $log,$realtimeConnection, $skipRenewCheck);
}

View file

@ -73,8 +73,8 @@ class Databases extends Action
$collection = new Document($payload['collection'] ?? []);
$document = new Document($payload['document'] ?? []);
$database = new Document($payload['database'] ?? []);
$this->sourceRegion = $payload['sourceRegion'] ?? 'default';
$log->addTag('projectId', $project->getId());
$log->addTag('type', $type);

View file

@ -101,7 +101,6 @@ class Functions extends Action
$this->sourceRegion = $payload['sourceRegion'] ?? 'default';
if ($function->isEmpty() && !empty($functionId)) {
$function = $dbForProject->getDocument('functions', $functionId);
}