get project db key by region
This commit is contained in:
parent
6b3051f131
commit
d6dfe7dfb3
2 changed files with 66 additions and 69 deletions
|
@ -133,6 +133,12 @@ App::post('/v1/projects')
|
||||||
throw new Exception(Exception::PROJECT_RESERVED_PROJECT, "'console' is a reserved project.");
|
throw new Exception(Exception::PROJECT_RESERVED_PROJECT, "'console' is a reserved project.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var_dump([
|
||||||
|
'_APP_DATABASE_SHARED_TABLES' => System::getEnv('_APP_DATABASE_SHARED_TABLES', ''),
|
||||||
|
'region' => $region,
|
||||||
|
'dsn' => $dsn,
|
||||||
|
]);
|
||||||
|
|
||||||
// TODO: Temporary until all projects are using shared tables.
|
// TODO: Temporary until all projects are using shared tables.
|
||||||
$sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', ''));
|
$sharedTablesKeys = explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', ''));
|
||||||
if (in_array($dsn->getHost(), $sharedTablesKeys)) {
|
if (in_array($dsn->getHost(), $sharedTablesKeys)) {
|
||||||
|
@ -146,12 +152,6 @@ App::post('/v1/projects')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var_dump([
|
|
||||||
'_APP_DATABASE_SHARED_TABLES' => System::getEnv('_APP_DATABASE_SHARED_TABLES', ''),
|
|
||||||
'region' => $region,
|
|
||||||
'dsn' => $dsn,
|
|
||||||
]);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$project = $dbForConsole->createDocument('projects', new Document([
|
$project = $dbForConsole->createDocument('projects', new Document([
|
||||||
'$id' => $projectId,
|
'$id' => $projectId,
|
||||||
|
|
|
@ -52,6 +52,7 @@ $parseLabel = function (string $label, array $responsePayload, array $requestPar
|
||||||
$label = \str_replace($find, $params[$replace], $label);
|
$label = \str_replace($find, $params[$replace], $label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $label;
|
return $label;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -93,8 +94,7 @@ $databaseListener = function (string $event, Document $document, Document $proje
|
||||||
$databaseInternalId = $parts[1] ?? 0;
|
$databaseInternalId = $parts[1] ?? 0;
|
||||||
$queueForUsage
|
$queueForUsage
|
||||||
->addMetric(METRIC_COLLECTIONS, $value) // per project
|
->addMetric(METRIC_COLLECTIONS, $value) // per project
|
||||||
->addMetric(str_replace('{databaseInternalId}', $databaseInternalId, METRIC_DATABASE_ID_COLLECTIONS), $value) // per database
|
->addMetric(str_replace('{databaseInternalId}', $databaseInternalId, METRIC_DATABASE_ID_COLLECTIONS), $value); // per database
|
||||||
;
|
|
||||||
|
|
||||||
if ($event === Database::EVENT_DOCUMENT_DELETE) {
|
if ($event === Database::EVENT_DOCUMENT_DELETE) {
|
||||||
$queueForUsage
|
$queueForUsage
|
||||||
|
@ -273,7 +273,7 @@ App::init()
|
||||||
throw new Exception(Exception::GENERAL_UNAUTHORIZED_SCOPE, $user->getAttribute('email', 'User').' (role: '.\strtolower($roles[$role]['label']).') missing scope ('.$scope.')');
|
throw new Exception(Exception::GENERAL_UNAUTHORIZED_SCOPE, $user->getAttribute('email', 'User').' (role: '.\strtolower($roles[$role]['label']).') missing scope ('.$scope.')');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false === $user->getAttribute('status')) { // Account is blocked
|
if ($user->getAttribute('status') === false) { // Account is blocked
|
||||||
throw new Exception(Exception::USER_BLOCKED);
|
throw new Exception(Exception::USER_BLOCKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,8 +466,7 @@ App::init()
|
||||||
->addHeader('Cache-Control', 'no-cache, no-store, must-revalidate')
|
->addHeader('Cache-Control', 'no-cache, no-store, must-revalidate')
|
||||||
->addHeader('Pragma', 'no-cache')
|
->addHeader('Pragma', 'no-cache')
|
||||||
->addHeader('Expires', 0)
|
->addHeader('Expires', 0)
|
||||||
->addHeader('X-Appwrite-Cache', 'miss')
|
->addHeader('X-Appwrite-Cache', 'miss');
|
||||||
;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -597,7 +596,7 @@ App::shutdown()
|
||||||
roles: $target['roles'],
|
roles: $target['roles'],
|
||||||
options: [
|
options: [
|
||||||
'permissionsChanged' => $target['permissionsChanged'],
|
'permissionsChanged' => $target['permissionsChanged'],
|
||||||
'userId' => $queueForEvents->getParam('userId')
|
'userId' => $queueForEvents->getParam('userId'),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -699,8 +698,6 @@ App::shutdown()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($project->getId() !== 'console') {
|
if ($project->getId() !== 'console') {
|
||||||
if (! Auth::isPrivilegedUser(Authorization::getRoles())) {
|
if (! Auth::isPrivilegedUser(Authorization::getRoles())) {
|
||||||
$fileSize = 0;
|
$fileSize = 0;
|
||||||
|
@ -728,7 +725,7 @@ App::shutdown()
|
||||||
if (DateTime::formatTz(DateTime::addSeconds(new \DateTime(), -APP_USER_ACCCESS)) > $accessedAt) {
|
if (DateTime::formatTz(DateTime::addSeconds(new \DateTime(), -APP_USER_ACCCESS)) > $accessedAt) {
|
||||||
$user->setAttribute('accessedAt', DateTime::now());
|
$user->setAttribute('accessedAt', DateTime::now());
|
||||||
|
|
||||||
if (APP_MODE_ADMIN !== $mode) {
|
if ($mode !== APP_MODE_ADMIN) {
|
||||||
$dbForProject->updateDocument('users', $user->getId(), $user);
|
$dbForProject->updateDocument('users', $user->getId(), $user);
|
||||||
} else {
|
} else {
|
||||||
$dbForConsole->updateDocument('users', $user->getId(), $user);
|
$dbForConsole->updateDocument('users', $user->getId(), $user);
|
||||||
|
|
Loading…
Reference in a new issue