From df943c62ca674d75278c8e00e43b4fe01cf14868 Mon Sep 17 00:00:00 2001
From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com>
Date: Fri, 21 Mar 2025 17:53:22 +0530
Subject: [PATCH 01/18] Add test for permanent redirect
---
.../Services/Sites/SitesCustomServerTest.php | 37 +++++++++++++++++++
tests/resources/sites/subProjects/index.html | 17 +++++++++
.../sites/subProjects/project1/index.html | 13 +++++++
.../sites/subProjects/project2/index.html | 13 +++++++
4 files changed, 80 insertions(+)
create mode 100644 tests/resources/sites/subProjects/index.html
create mode 100644 tests/resources/sites/subProjects/project1/index.html
create mode 100644 tests/resources/sites/subProjects/project2/index.html
diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php
index a95568c7ce..e4ff30f86e 100644
--- a/tests/e2e/Services/Sites/SitesCustomServerTest.php
+++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php
@@ -2331,4 +2331,41 @@ class SitesCustomServerTest extends Scope
$this->cleanupSite($siteId);
}
+
+ public function testSubProjects(): void
+ {
+ $siteId = $this->setupSite([
+ 'siteId' => ID::unique(),
+ 'name' => 'Sub project site',
+ 'framework' => 'other',
+ 'buildRuntime' => 'node-22',
+ 'outputDirectory' => './'
+ ]);
+ $this->assertNotEmpty($siteId);
+
+ $site = $this->getSite($siteId);
+ $this->assertEquals('200', $site['headers']['status-code']);
+ $this->assertArrayHasKey('adapter', $site['body']);
+
+ $domain = $this->setupSiteDomain($siteId);
+ $this->assertNotEmpty($domain);
+
+ $deploymentId = $this->setupDeployment($siteId, [
+ 'code' => $this->packageSite('subProjects'),
+ 'activate' => 'true'
+ ]);
+ $this->assertNotEmpty($deploymentId);
+
+ $site = $this->getSite($siteId);
+
+ $proxyClient = new Client();
+ $proxyClient->setEndpoint('http://' . $domain);
+ $response = $proxyClient->call(Client::METHOD_GET, '/');
+ $this->assertEquals(200, $response['headers']['status-code']);
+ $response1 = $proxyClient->call(Client::METHOD_GET, '/project1');
+ $this->assertEquals(200, $response1['headers']['status-code']);
+ $response2 = $proxyClient->call(Client::METHOD_GET, '/project1/');
+ $this->assertEquals(308, $response2['headers']['status-code']);
+ $this->cleanupSite($siteId);
+ }
}
diff --git a/tests/resources/sites/subProjects/index.html b/tests/resources/sites/subProjects/index.html
new file mode 100644
index 0000000000..cb9af4b5ac
--- /dev/null
+++ b/tests/resources/sites/subProjects/index.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+ Main Project Index
+
+
+ Welcome to My Website
+ Select a project to explore:
+
+
+
+
diff --git a/tests/resources/sites/subProjects/project1/index.html b/tests/resources/sites/subProjects/project1/index.html
new file mode 100644
index 0000000000..43b5eae40b
--- /dev/null
+++ b/tests/resources/sites/subProjects/project1/index.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+ Project 1
+
+
+ Project 1
+ Welcome to Project 1!
+ Back to Main Page
+
+
diff --git a/tests/resources/sites/subProjects/project2/index.html b/tests/resources/sites/subProjects/project2/index.html
new file mode 100644
index 0000000000..5fea34c1ce
--- /dev/null
+++ b/tests/resources/sites/subProjects/project2/index.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+ Project 2
+
+
+ Project 2
+ Welcome to Project 2!
+ Back to Main Page
+
+
From 65aa218aac1c742c232019e10f66d7107114369f Mon Sep 17 00:00:00 2001
From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com>
Date: Fri, 21 Mar 2025 17:54:07 +0530
Subject: [PATCH 02/18] Add test for permanent redirect
---
tests/e2e/Services/Sites/SitesCustomServerTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php
index e4ff30f86e..cc2e1f9bbb 100644
--- a/tests/e2e/Services/Sites/SitesCustomServerTest.php
+++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php
@@ -2332,7 +2332,7 @@ class SitesCustomServerTest extends Scope
$this->cleanupSite($siteId);
}
- public function testSubProjects(): void
+ public function testPermanentRedirect(): void
{
$siteId = $this->setupSite([
'siteId' => ID::unique(),
From 2e0a6f9b9ebefd0dff756a8c49b3dae6eb7c4bdf Mon Sep 17 00:00:00 2001
From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com>
Date: Wed, 26 Mar 2025 17:22:49 +0530
Subject: [PATCH 03/18] Update swoole version
---
composer.lock | 16 ++++++++--------
.../e2e/Services/Sites/SitesCustomServerTest.php | 2 +-
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/composer.lock b/composer.lock
index ee5f16f7c9..88cb3586d6 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4700,16 +4700,16 @@
},
{
"name": "utopia-php/swoole",
- "version": "0.8.2",
+ "version": "0.8.3",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/swoole.git",
- "reference": "5fa9d42c608ad46a4ce42a6d2b2eae00592fccd4"
+ "reference": "1af73dd3e73987cf729c7db399054e4a70befd99"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/utopia-php/swoole/zipball/5fa9d42c608ad46a4ce42a6d2b2eae00592fccd4",
- "reference": "5fa9d42c608ad46a4ce42a6d2b2eae00592fccd4",
+ "url": "https://api.github.com/repos/utopia-php/swoole/zipball/1af73dd3e73987cf729c7db399054e4a70befd99",
+ "reference": "1af73dd3e73987cf729c7db399054e4a70befd99",
"shasum": ""
},
"require": {
@@ -4745,9 +4745,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/swoole/issues",
- "source": "https://github.com/utopia-php/swoole/tree/0.8.2"
+ "source": "https://github.com/utopia-php/swoole/tree/0.8.3"
},
- "time": "2024-02-01T14:54:12+00:00"
+ "time": "2025-03-26T10:09:05+00:00"
},
{
"name": "utopia-php/system",
@@ -8507,7 +8507,7 @@
],
"aliases": [],
"minimum-stability": "stable",
- "stability-flags": [],
+ "stability-flags": {},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
@@ -8531,5 +8531,5 @@
"platform-overrides": {
"php": "8.3"
},
- "plugin-api-version": "2.3.0"
+ "plugin-api-version": "2.6.0"
}
diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php
index 99a1c47f42..ec941a9f56 100644
--- a/tests/e2e/Services/Sites/SitesCustomServerTest.php
+++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php
@@ -2427,7 +2427,7 @@ class SitesCustomServerTest extends Scope
$response1 = $proxyClient->call(Client::METHOD_GET, '/project1');
$this->assertEquals(200, $response1['headers']['status-code']);
$response2 = $proxyClient->call(Client::METHOD_GET, '/project1/');
- $this->assertEquals(308, $response2['headers']['status-code']);
+ $this->assertEquals(200, $response2['headers']['status-code']);
$this->cleanupSite($siteId);
}
}
From ab03b4e3caa62347066912d520073eefec6abee2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ba=C4=8Do?=
Date: Wed, 26 Mar 2025 12:59:05 +0100
Subject: [PATCH 04/18] Deployment ready after screenshot
---
app/config/frameworks.php | 2 +-
app/controllers/general.php | 5 +-
src/Appwrite/Auth/Key.php | 10 +++-
.../Modules/Functions/Workers/Builds.php | 48 +++++++++++++------
4 files changed, 46 insertions(+), 19 deletions(-)
diff --git a/app/config/frameworks.php b/app/config/frameworks.php
index 82fd70bf5b..5440e9a538 100644
--- a/app/config/frameworks.php
+++ b/app/config/frameworks.php
@@ -138,7 +138,7 @@ return [
'vue' => [
'key' => 'vue',
'name' => 'Vue.js',
- 'screenshotSleep' => 3000,
+ 'screenshotSleep' => 5000,
'buildRuntime' => 'node-22',
'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'),
'adapters' => [
diff --git a/app/controllers/general.php b/app/controllers/general.php
index 3f105484e1..13dec5dac9 100644
--- a/app/controllers/general.php
+++ b/app/controllers/general.php
@@ -268,8 +268,9 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw
if (\is_null($runtime)) {
throw new AppwriteException(AppwriteException::FUNCTION_RUNTIME_UNSUPPORTED, 'Runtime "' . $resource->getAttribute('runtime', '') . '" is not supported');
}
-
- if ($deployment->getAttribute('status') !== 'ready') {
+
+ $allowAnyStatus = !\is_null($apiKey) && $apiKey->isDeploymentStatusIgnored();
+ if (!$allowAnyStatus && $deployment->getAttribute('status') !== 'ready') {
throw new AppwriteException(AppwriteException::BUILD_NOT_READY);
}
diff --git a/src/Appwrite/Auth/Key.php b/src/Appwrite/Auth/Key.php
index 89c28c4727..87e77b2e06 100644
--- a/src/Appwrite/Auth/Key.php
+++ b/src/Appwrite/Auth/Key.php
@@ -24,6 +24,7 @@ class Key
protected bool $bannerDisabled = false,
protected bool $projectCheckDisabled = false,
protected bool $previewAuthDisabled = false,
+ protected bool $deploymentStatusIgnored = false,
) {
}
@@ -78,6 +79,11 @@ class Key
{
return $this->previewAuthDisabled;
}
+
+ public function isDeploymentStatusIgnored(): bool
+ {
+ return $this->deploymentStatusIgnored;
+ }
public function isProjectCheckDisabled(): bool
{
@@ -139,6 +145,7 @@ class Key
$bannerDisabled = $payload['bannerDisabled'] ?? false;
$projectCheckDisabled = $payload['projectCheckDisabled'] ?? false;
$previewAuthDisabled = $payload['previewAuthDisabled'] ?? false;
+ $deploymentStatusIgnored = $payload['deploymentStatusIgnored'] ?? false;
$scopes = \array_merge($payload['scopes'] ?? [], $scopes);
if (!$projectCheckDisabled && $projectId !== $project->getId()) {
@@ -156,7 +163,8 @@ class Key
$hostnameOverride,
$bannerDisabled,
$projectCheckDisabled,
- $previewAuthDisabled
+ $previewAuthDisabled,
+ $deploymentStatusIgnored
);
case API_KEY_STANDARD:
$key = $project->find(
diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php
index 3f28e7a7ce..849fd514d0 100644
--- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php
+++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php
@@ -778,24 +778,26 @@ class Builds extends Action
}
$executor->deleteRuntime($project->getId(), $deployment->getId(), '-build');
-
+
/** Update the build document */
$deployment->setAttribute('buildStartAt', DateTime::format((new \DateTime())->setTimestamp(floor($response['startTime']))));
$deployment->setAttribute('buildEndAt', $endTime);
$deployment->setAttribute('buildDuration', \intval(\ceil($durationEnd - $durationStart)));
- $deployment->setAttribute('status', 'ready');
$deployment->setAttribute('buildPath', $response['path']);
$deployment->setAttribute('buildSize', $response['size']);
$deployment->setAttribute('totalSize', $deployment->getAttribute('buildSize', 0) + $deployment->getAttribute('sourceSize', 0));
-
+
$logs = '';
foreach ($response['output'] as $log) {
$logs .= $log['content'];
}
+ $logs .= "[0mCapturing screenshots ...\n";
$deployment->setAttribute('buildLogs', $logs);
+
+ $deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);
$deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment);
-
+
if ($deployment->getInternalId() === $resource->getAttribute('latestDeploymentInternalId', '')) {
$resource = $resource->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', ''));
$dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource);
@@ -804,13 +806,8 @@ class Builds extends Action
$queueForRealtime
->setPayload($deployment->getArrayCopy())
->trigger();
-
- if ($isVcsEnabled) {
- $this->runGitAction('ready', $github, $providerCommitHash, $owner, $repositoryName, $project, $resource, $deployment->getId(), $dbForProject, $dbForPlatform);
- }
-
- Console::success("Build id: $deploymentId created");
-
+
+ /** Screenshot site */
if ($resource->getCollection() === 'sites') {
try {
$rule = Authorization::skip(fn () => $dbForPlatform->findOne('rules', [
@@ -848,6 +845,7 @@ class Builds extends Action
'bannerDisabled' => true,
'projectCheckDisabled' => true,
'previewAuthDisabled' => true,
+ 'deploymentStatusIgnored' => true
]);
// TODO: @Meldiron if becomes too slow, do concurrently
@@ -864,17 +862,17 @@ class Builds extends Action
$config['sleep'] = $framework['screenshotSleep'];
}
- $response = $client->fetch(
+ $fetchResponse = $client->fetch(
url: 'http://appwrite-browser:3000/v1/screenshots',
method: 'POST',
body: $config
);
- if ($response->getStatusCode() >= 400) {
- throw new \Exception($response->getBody());
+ if ($fetchResponse->getStatusCode() >= 400) {
+ throw new \Exception($fetchResponse->getBody());
}
- $screenshot = $response->getBody();
+ $screenshot = $fetchResponse->getBody();
$fileId = ID::unique();
$fileName = $fileId . '.png';
@@ -928,6 +926,20 @@ class Builds extends Action
}
}
+ /** Update the status */
+ $deployment->setAttribute('status', 'ready');
+ $deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment);
+
+ $queueForRealtime
+ ->setPayload($deployment->getArrayCopy())
+ ->trigger();
+
+ if ($isVcsEnabled) {
+ $this->runGitAction('ready', $github, $providerCommitHash, $owner, $repositoryName, $project, $resource, $deployment->getId(), $dbForProject, $dbForPlatform);
+ }
+
+ Console::success("Build id: $deploymentId created");
+
/** Set auto deploy */
if ($deployment->getAttribute('activate') === true) {
$resource->setAttribute('live', true);
@@ -1066,6 +1078,12 @@ class Builds extends Action
Authorization::skip(fn () => $dbForPlatform->updateDocument('schedules', $schedule->getId(), $schedule));
}
} catch (\Throwable $th) {
+ Console::warning('Build failed:');
+ Console::error($th->getMessage());
+ Console::error($th->getFile());
+ Console::error($th->getLine());
+ Console::error($th->getTraceAsString());
+
if ($dbForProject->getDocument('deployments', $deploymentId)->getAttribute('status') === 'canceled') {
Console::info('Build has been canceled');
return;
From 681b6031aa5dfc85bd78796d7f05e85a339e7023 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ba=C4=8Do?=
Date: Wed, 26 Mar 2025 12:59:15 +0100
Subject: [PATCH 05/18] Linter fix
---
app/controllers/general.php | 2 +-
src/Appwrite/Auth/Key.php | 2 +-
.../Platform/Modules/Functions/Workers/Builds.php | 12 ++++++------
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/app/controllers/general.php b/app/controllers/general.php
index 13dec5dac9..006584c954 100644
--- a/app/controllers/general.php
+++ b/app/controllers/general.php
@@ -268,7 +268,7 @@ function router(App $utopia, Database $dbForPlatform, callable $getProjectDB, Sw
if (\is_null($runtime)) {
throw new AppwriteException(AppwriteException::FUNCTION_RUNTIME_UNSUPPORTED, 'Runtime "' . $resource->getAttribute('runtime', '') . '" is not supported');
}
-
+
$allowAnyStatus = !\is_null($apiKey) && $apiKey->isDeploymentStatusIgnored();
if (!$allowAnyStatus && $deployment->getAttribute('status') !== 'ready') {
throw new AppwriteException(AppwriteException::BUILD_NOT_READY);
diff --git a/src/Appwrite/Auth/Key.php b/src/Appwrite/Auth/Key.php
index 87e77b2e06..44a75a6ee3 100644
--- a/src/Appwrite/Auth/Key.php
+++ b/src/Appwrite/Auth/Key.php
@@ -79,7 +79,7 @@ class Key
{
return $this->previewAuthDisabled;
}
-
+
public function isDeploymentStatusIgnored(): bool
{
return $this->deploymentStatusIgnored;
diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php
index 849fd514d0..b18b6e4004 100644
--- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php
+++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php
@@ -778,7 +778,7 @@ class Builds extends Action
}
$executor->deleteRuntime($project->getId(), $deployment->getId(), '-build');
-
+
/** Update the build document */
$deployment->setAttribute('buildStartAt', DateTime::format((new \DateTime())->setTimestamp(floor($response['startTime']))));
$deployment->setAttribute('buildEndAt', $endTime);
@@ -786,18 +786,18 @@ class Builds extends Action
$deployment->setAttribute('buildPath', $response['path']);
$deployment->setAttribute('buildSize', $response['size']);
$deployment->setAttribute('totalSize', $deployment->getAttribute('buildSize', 0) + $deployment->getAttribute('sourceSize', 0));
-
+
$logs = '';
foreach ($response['output'] as $log) {
$logs .= $log['content'];
}
$logs .= "[0mCapturing screenshots ...\n";
$deployment->setAttribute('buildLogs', $logs);
-
+
$deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);
$deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment);
-
+
if ($deployment->getInternalId() === $resource->getAttribute('latestDeploymentInternalId', '')) {
$resource = $resource->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', ''));
$dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource);
@@ -806,7 +806,7 @@ class Builds extends Action
$queueForRealtime
->setPayload($deployment->getArrayCopy())
->trigger();
-
+
/** Screenshot site */
if ($resource->getCollection() === 'sites') {
try {
@@ -1083,7 +1083,7 @@ class Builds extends Action
Console::error($th->getFile());
Console::error($th->getLine());
Console::error($th->getTraceAsString());
-
+
if ($dbForProject->getDocument('deployments', $deploymentId)->getAttribute('status') === 'canceled') {
Console::info('Build has been canceled');
return;
From 2c55f5aaa607f01e12fe0680a539100f5f18f6ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ba=C4=8Do?=
Date: Wed, 26 Mar 2025 13:20:14 +0100
Subject: [PATCH 06/18] Concurrency screenshots
---
.../Modules/Functions/Workers/Builds.php | 117 ++++++++++--------
1 file changed, 63 insertions(+), 54 deletions(-)
diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php
index b18b6e4004..eecc439642 100644
--- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php
+++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php
@@ -41,6 +41,8 @@ use Utopia\Storage\Device\Local;
use Utopia\System\System;
use Utopia\VCS\Adapter\Git\GitHub;
+use function Swoole\Coroutine\batch;
+
class Builds extends Action
{
public static function getName(): string
@@ -849,69 +851,76 @@ class Builds extends Action
]);
// TODO: @Meldiron if becomes too slow, do concurrently
- foreach ($configs as $key => $config) {
- $config['headers'] = \array_merge($config['headers'] ?? [], [
- 'x-appwrite-key' => API_KEY_DYNAMIC . '_' . $apiKey
- ]);
+ $screenshots = batch(\array_map(function ($key) use ($configs, $deviceForFiles, $apiKey, $resource, $client, $bucket, $project, $dbForPlatform) {
+ return function () use ($key, $configs, $deviceForFiles, $apiKey, $resource, $client, $bucket, $project, $dbForPlatform) {
+ $config = $configs[$key];
- $config['sleep'] = 3000;
+ $config['headers'] = \array_merge($config['headers'] ?? [], [
+ 'x-appwrite-key' => API_KEY_DYNAMIC . '_' . $apiKey
+ ]);
+ $config['sleep'] = 3000;
- $frameworks = Config::getParam('frameworks', []);
- $framework = $frameworks[$resource->getAttribute('framework', '')] ?? null;
- if (!is_null($framework)) {
- $config['sleep'] = $framework['screenshotSleep'];
- }
+ $frameworks = Config::getParam('frameworks', []);
+ $framework = $frameworks[$resource->getAttribute('framework', '')] ?? null;
+ if (!is_null($framework)) {
+ $config['sleep'] = $framework['screenshotSleep'];
+ }
- $fetchResponse = $client->fetch(
- url: 'http://appwrite-browser:3000/v1/screenshots',
- method: 'POST',
- body: $config
- );
+ $fetchResponse = $client->fetch(
+ url: 'http://appwrite-browser:3000/v1/screenshots',
+ method: 'POST',
+ body: $config
+ );
- if ($fetchResponse->getStatusCode() >= 400) {
- throw new \Exception($fetchResponse->getBody());
- }
+ if ($fetchResponse->getStatusCode() >= 400) {
+ throw new \Exception($fetchResponse->getBody());
+ }
- $screenshot = $fetchResponse->getBody();
+ $screenshot = $fetchResponse->getBody();
- $fileId = ID::unique();
- $fileName = $fileId . '.png';
- $path = $deviceForFiles->getPath($fileName);
- $path = str_ireplace($deviceForFiles->getRoot(), $deviceForFiles->getRoot() . DIRECTORY_SEPARATOR . $bucket->getId(), $path); // Add bucket id to path after root
- $success = $deviceForFiles->write($path, $screenshot, "image/png");
+ $fileId = ID::unique();
+ $fileName = $fileId . '.png';
+ $path = $deviceForFiles->getPath($fileName);
+ $path = str_ireplace($deviceForFiles->getRoot(), $deviceForFiles->getRoot() . DIRECTORY_SEPARATOR . $bucket->getId(), $path); // Add bucket id to path after root
+ $success = $deviceForFiles->write($path, $screenshot, "image/png");
- if (!$success) {
- throw new \Exception("Screenshot failed to save");
- }
+ if (!$success) {
+ throw new \Exception("Screenshot failed to save");
+ }
- $teamId = $project->getAttribute('teamId', '');
- $file = new Document([
- '$id' => $fileId,
- '$permissions' => [
- Permission::read(Role::team(ID::custom($teamId))),
- ],
- 'bucketId' => $bucket->getId(),
- 'bucketInternalId' => $bucket->getInternalId(),
- 'name' => $fileName,
- 'path' => $path,
- 'signature' => $deviceForFiles->getFileHash($path),
- 'mimeType' => $deviceForFiles->getFileMimeType($path),
- 'sizeOriginal' => \strlen($screenshot),
- 'sizeActual' => $deviceForFiles->getFileSize($path),
- 'algorithm' => Compression::GZIP,
- 'comment' => '',
- 'chunksTotal' => 1,
- 'chunksUploaded' => 1,
- 'openSSLVersion' => null,
- 'openSSLCipher' => null,
- 'openSSLTag' => null,
- 'openSSLIV' => null,
- 'search' => implode(' ', [$fileId, $fileName]),
- 'metadata' => ['content_type' => $deviceForFiles->getFileMimeType($path)],
- ]);
- $file = Authorization::skip(fn () => $dbForPlatform->createDocument('bucket_' . $bucket->getInternalId(), $file));
+ $teamId = $project->getAttribute('teamId', '');
+ $file = new Document([
+ '$id' => $fileId,
+ '$permissions' => [
+ Permission::read(Role::team(ID::custom($teamId))),
+ ],
+ 'bucketId' => $bucket->getId(),
+ 'bucketInternalId' => $bucket->getInternalId(),
+ 'name' => $fileName,
+ 'path' => $path,
+ 'signature' => $deviceForFiles->getFileHash($path),
+ 'mimeType' => $deviceForFiles->getFileMimeType($path),
+ 'sizeOriginal' => \strlen($screenshot),
+ 'sizeActual' => $deviceForFiles->getFileSize($path),
+ 'algorithm' => Compression::GZIP,
+ 'comment' => '',
+ 'chunksTotal' => 1,
+ 'chunksUploaded' => 1,
+ 'openSSLVersion' => null,
+ 'openSSLCipher' => null,
+ 'openSSLTag' => null,
+ 'openSSLIV' => null,
+ 'search' => implode(' ', [$fileId, $fileName]),
+ 'metadata' => ['content_type' => $deviceForFiles->getFileMimeType($path)],
+ ]);
+ $file = Authorization::skip(fn () => $dbForPlatform->createDocument('bucket_' . $bucket->getInternalId(), $file));
- $deployment->setAttribute($key, $fileId);
+ return [ 'key' => $key, 'fileId' => $fileId ];
+ };
+ }, \array_keys($configs)));
+
+ foreach ($screenshots as $screenshot) {
+ $deployment->setAttribute($screenshot['key'], $screenshot['fileId']);
}
$dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);
From 62be0e1d00eab357da3482080fb617496fb47728 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ba=C4=8Do?=
Date: Wed, 26 Mar 2025 14:38:18 +0100
Subject: [PATCH 07/18] Fix latest deployment attributes
---
.../Platform/Modules/Functions/Workers/Builds.php | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php
index eecc439642..d2ef6deb36 100644
--- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php
+++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php
@@ -798,13 +798,6 @@ class Builds extends Action
$deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);
- $deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment);
-
- if ($deployment->getInternalId() === $resource->getAttribute('latestDeploymentInternalId', '')) {
- $resource = $resource->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', ''));
- $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource);
- }
-
$queueForRealtime
->setPayload($deployment->getArrayCopy())
->trigger();
@@ -938,6 +931,11 @@ class Builds extends Action
/** Update the status */
$deployment->setAttribute('status', 'ready');
$deployment = $dbForProject->updateDocument('deployments', $deploymentId, $deployment);
+
+ if ($deployment->getInternalId() === $resource->getAttribute('latestDeploymentInternalId', '')) {
+ $resource = $resource->setAttribute('latestDeploymentStatus', $deployment->getAttribute('status', ''));
+ $dbForProject->updateDocument($resource->getCollection(), $resource->getId(), $resource);
+ }
$queueForRealtime
->setPayload($deployment->getArrayCopy())
From 70fbf69c5689da448716d9f47c156cb0db60bd2c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ba=C4=8Do?=
Date: Wed, 26 Mar 2025 14:38:27 +0100
Subject: [PATCH 08/18] Fix fonts
---
app/views/general/404.phtml | 10 ++++++----
src/Appwrite/Transformation/Adapter/Preview.php | 8 +++++---
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/app/views/general/404.phtml b/app/views/general/404.phtml
index 7ec1cfbf21..5e63344c8a 100644
--- a/app/views/general/404.phtml
+++ b/app/views/general/404.phtml
@@ -7,6 +7,8 @@
404 Not Found