mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Merge branch '1.9.x' into fix-10923-realtime-atomic-payload
This commit is contained in:
@@ -130,10 +130,25 @@ class Create extends CollectionAction
|
||||
$indexes[] = new Document($index);
|
||||
}
|
||||
try {
|
||||
if (!$dbForDatabases->exists(null, Database::METADATA)) {
|
||||
// Bootstrap the database metadata without a separate existence
|
||||
// check to avoid races when multiple first collections are created
|
||||
// concurrently for the same VectorsDB database.
|
||||
for ($attempt = 0; $attempt < 5; $attempt++) {
|
||||
try {
|
||||
$dbForDatabases->create();
|
||||
break;
|
||||
} catch (DuplicateException) {
|
||||
break;
|
||||
} catch (\Throwable $e) {
|
||||
if ($dbForDatabases->exists(null, Database::METADATA)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ($attempt === 4) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
\usleep(100_000);
|
||||
}
|
||||
}
|
||||
$dbForDatabases->createCollection(
|
||||
|
||||
@@ -74,10 +74,12 @@ class Update extends Action
|
||||
->inject('queueForEvents')
|
||||
->inject('store')
|
||||
->inject('proofForToken')
|
||||
->inject('domainVerification')
|
||||
->inject('cookieDomain')
|
||||
->callback($this->action(...));
|
||||
}
|
||||
|
||||
public function action(string $teamId, string $membershipId, string $userId, string $secret, Request $request, Response $response, Document $user, Database $dbForProject, Authorization $authorization, $project, Reader $geodb, Event $queueForEvents, Store $store, Token $proofForToken)
|
||||
public function action(string $teamId, string $membershipId, string $userId, string $secret, Request $request, Response $response, Document $user, Database $dbForProject, Authorization $authorization, $project, Reader $geodb, Event $queueForEvents, Store $store, Token $proofForToken, bool $domainVerification, ?string $cookieDomain)
|
||||
{
|
||||
$protocol = $request->getProtocol();
|
||||
|
||||
@@ -162,7 +164,7 @@ class Update extends Action
|
||||
->setProperty('secret', $secret)
|
||||
->encode();
|
||||
|
||||
if (!Config::getParam('domainVerification')) {
|
||||
if (!$domainVerification) {
|
||||
$response->addHeader('X-Fallback-Cookies', \json_encode([$store->getKey() => $encoded]));
|
||||
}
|
||||
|
||||
@@ -172,7 +174,7 @@ class Update extends Action
|
||||
value: $encoded,
|
||||
expire: (new \DateTime($expire))->getTimestamp(),
|
||||
path: '/',
|
||||
domain: Config::getParam('cookieDomain'),
|
||||
domain: $cookieDomain,
|
||||
secure: ('https' === $protocol),
|
||||
httponly: true
|
||||
)
|
||||
@@ -181,7 +183,7 @@ class Update extends Action
|
||||
value: $encoded,
|
||||
expire: (new \DateTime($expire))->getTimestamp(),
|
||||
path: '/',
|
||||
domain: Config::getParam('cookieDomain'),
|
||||
domain: $cookieDomain,
|
||||
secure: ('https' === $protocol),
|
||||
httponly: true,
|
||||
sameSite: Config::getParam('cookieSamesite')
|
||||
|
||||
@@ -210,6 +210,25 @@ abstract class Format
|
||||
return $this->services;
|
||||
}
|
||||
|
||||
protected function getDescriptionContents(?string $description): string
|
||||
{
|
||||
if ($description === null || $description === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!\str_ends_with($description, '.md')) {
|
||||
return $description;
|
||||
}
|
||||
|
||||
$contents = @\file_get_contents($description);
|
||||
|
||||
if ($contents === false) {
|
||||
throw new \RuntimeException('Documentation file not found or unreadable: ' . $description);
|
||||
}
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
protected function getRequestEnumName(string $service, string $method, string $param): ?string
|
||||
{
|
||||
/* `$service` is `$namespace` */
|
||||
|
||||
@@ -125,10 +125,7 @@ class OpenAPI3 extends Format
|
||||
|
||||
$namespace = $sdk->getNamespace() ?? 'default';
|
||||
|
||||
if ($desc === null) {
|
||||
$desc = '';
|
||||
}
|
||||
$descContents = \str_ends_with($desc, '.md') ? \file_get_contents($desc) : $desc;
|
||||
$descContents = $this->getDescriptionContents($desc);
|
||||
|
||||
$temp = [
|
||||
'summary' => $route->getDesc(),
|
||||
@@ -193,7 +190,7 @@ class OpenAPI3 extends Format
|
||||
'parameters' => [],
|
||||
'required' => [],
|
||||
'responses' => [],
|
||||
'description' => ($desc) ? \file_get_contents($desc) : '',
|
||||
'description' => $this->getDescriptionContents($desc),
|
||||
'demo' => \strtolower($namespace) . '/' . Template::fromCamelCaseToDash($methodObj->getMethodName()) . '.md',
|
||||
'public' => $methodObj->isPublic(),
|
||||
];
|
||||
|
||||
@@ -126,10 +126,7 @@ class Swagger2 extends Format
|
||||
$sdkPlatforms = array_values(array_unique($sdkPlatforms));
|
||||
$namespace = $sdk->getNamespace() ?? 'default';
|
||||
|
||||
if ($desc === null) {
|
||||
$desc = '';
|
||||
}
|
||||
$descContents = \str_ends_with($desc, '.md') ? \file_get_contents($desc) : $desc;
|
||||
$descContents = $this->getDescriptionContents($desc);
|
||||
|
||||
$temp = [
|
||||
'summary' => $route->getDesc(),
|
||||
@@ -201,7 +198,7 @@ class Swagger2 extends Format
|
||||
'parameters' => [],
|
||||
'required' => [],
|
||||
'responses' => [],
|
||||
'description' => ($desc) ? \file_get_contents($desc) : '',
|
||||
'description' => $this->getDescriptionContents($desc),
|
||||
'demo' => \strtolower($namespace) . '/' . Template::fromCamelCaseToDash($methodObj->getMethodName()) . '.md',
|
||||
'public' => $methodObj->isPublic(),
|
||||
];
|
||||
|
||||
@@ -17,7 +17,7 @@ class Request extends UtopiaRequest
|
||||
* @var array<Filter>
|
||||
*/
|
||||
private array $filters = [];
|
||||
private static ?Route $route = null;
|
||||
private ?Route $route = null;
|
||||
|
||||
public function __construct(SwooleRequest $request)
|
||||
{
|
||||
@@ -34,11 +34,11 @@ class Request extends UtopiaRequest
|
||||
{
|
||||
$parameters = parent::getParams();
|
||||
|
||||
if (!$this->hasFilters() || !self::hasRoute()) {
|
||||
if (!$this->hasFilters() || !$this->hasRoute()) {
|
||||
return $parameters;
|
||||
}
|
||||
|
||||
$methods = self::getRoute()->getLabel('sdk', null);
|
||||
$methods = $this->getRoute()?->getLabel('sdk', null);
|
||||
|
||||
if (empty($methods)) {
|
||||
return $parameters;
|
||||
@@ -131,9 +131,9 @@ class Request extends UtopiaRequest
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setRoute(?Route $route): void
|
||||
public function setRoute(?Route $route): void
|
||||
{
|
||||
self::$route = $route;
|
||||
$this->route = $route;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,9 +141,9 @@ class Request extends UtopiaRequest
|
||||
*
|
||||
* @return Route|null
|
||||
*/
|
||||
public static function getRoute(): ?Route
|
||||
public function getRoute(): ?Route
|
||||
{
|
||||
return self::$route;
|
||||
return $this->route;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,9 +151,9 @@ class Request extends UtopiaRequest
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasRoute(): bool
|
||||
public function hasRoute(): bool
|
||||
{
|
||||
return self::$route !== null;
|
||||
return $this->route !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -299,7 +299,7 @@ class Response extends SwooleResponse
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected static bool $showSensitive = false;
|
||||
protected bool $showSensitive = false;
|
||||
|
||||
/**
|
||||
* @var array<string, Model>
|
||||
@@ -509,7 +509,7 @@ class Response extends SwooleResponse
|
||||
$isPrivilegedUser = $user->isPrivileged($roles);
|
||||
$isAppUser = $user->isApp($roles);
|
||||
|
||||
if ((!$isPrivilegedUser && !$isAppUser) && !self::$showSensitive) {
|
||||
if ((!$isPrivilegedUser && !$isAppUser) && !$this->showSensitive) {
|
||||
$data->setAttribute($key, '');
|
||||
}
|
||||
}
|
||||
@@ -659,18 +659,20 @@ class Response extends SwooleResponse
|
||||
}
|
||||
|
||||
/**
|
||||
* Static wrapper to show sensitive data in response
|
||||
* Wrapper to show sensitive data in response
|
||||
*
|
||||
* @param callable(): array $callback The callback to show sensitive information for
|
||||
* @return array
|
||||
*/
|
||||
public static function showSensitive(callable $callback): array
|
||||
public function showSensitive(callable $callback): array
|
||||
{
|
||||
$previous = $this->showSensitive;
|
||||
|
||||
try {
|
||||
self::$showSensitive = true;
|
||||
$this->showSensitive = true;
|
||||
return $callback();
|
||||
} finally {
|
||||
self::$showSensitive = false;
|
||||
$this->showSensitive = $previous;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user