mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Fix bugs
This commit is contained in:
@@ -585,7 +585,7 @@ App::init()
|
||||
*/
|
||||
|
||||
App::init()
|
||||
->groups(['database', 'functions', 'storage', 'messaging'])
|
||||
->groups(['database', 'functions', 'messaging'])
|
||||
->inject('project')
|
||||
->inject('request')
|
||||
->action(function (Document $project, Request $request) {
|
||||
|
||||
@@ -269,6 +269,9 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg
|
||||
'fileSecurity' => true,
|
||||
'$permissions' => [
|
||||
Permission::create(Role::any()),
|
||||
Permission::read(Role::any()),
|
||||
Permission::update(Role::any()),
|
||||
Permission::delete(Role::any()),
|
||||
],
|
||||
'search' => 'buckets Screenshots',
|
||||
]));
|
||||
|
||||
+2
-1
@@ -1911,8 +1911,9 @@ App::setResource(
|
||||
);
|
||||
|
||||
App::setResource('previewHostname', function (Request $request) {
|
||||
// TODO: @Meldiron Allow in production too for internal communication (authorized with secret)
|
||||
if (App::isDevelopment()) {
|
||||
$host = $request->getQuery('appwrite-hostname') ?? '';
|
||||
$host = $request->getQuery('appwrite-hostname', $request->getHeader('x-appwrite-hostname', ''));
|
||||
if (!empty($host)) {
|
||||
return $host;
|
||||
}
|
||||
|
||||
@@ -433,6 +433,7 @@ services:
|
||||
volumes:
|
||||
- appwrite-functions:/storage/functions:rw
|
||||
- appwrite-builds:/storage/builds:rw
|
||||
- appwrite-uploads:/storage/uploads:rw
|
||||
- ./app:/usr/src/code/app
|
||||
- ./src:/usr/src/code/src
|
||||
depends_on:
|
||||
|
||||
@@ -717,16 +717,22 @@ class Builds extends Action
|
||||
Query::equal("resourceInternalId", [$deployment->getInternalId()])
|
||||
]));
|
||||
|
||||
if(!$rule->isEmpty()) {
|
||||
if($rule->isEmpty()) {
|
||||
throw new \Exception("Rule for build not found");
|
||||
}
|
||||
|
||||
|
||||
$client = new FetchClient();
|
||||
$client->addHeader('Authorization', 'Bearer ' . App::getEnv('_APP_OPENSSL_KEY_V1', ''));
|
||||
$response = $client->fetch('http://appwrite-browser/screenshot', query: [
|
||||
'url' => 'http://' . $rule->getAttribute('domain') . '/'
|
||||
$response = $client->fetch('http://appwrite-browser:3000/screenshot', query: [
|
||||
'hostname' => $rule->getAttribute('domain'),
|
||||
'path' => '/',
|
||||
]);
|
||||
|
||||
if($response->getStatusCode() >= 400) {
|
||||
throw new \Exception("Screenshot failed to generate: " . $response->getBody());
|
||||
}
|
||||
|
||||
$screenshot = $response->getBody();
|
||||
|
||||
$bucket = $dbForPlatform->getDocument('buckets', 'screenshots');
|
||||
@@ -736,7 +742,7 @@ class Builds extends Action
|
||||
$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");
|
||||
$success = $deviceForFiles->write($path, $screenshot, "image/png");
|
||||
|
||||
if(!$success) {
|
||||
throw new \Exception("Screenshot failed to save");
|
||||
@@ -769,9 +775,9 @@ class Builds extends Action
|
||||
'openSSLTag' => null,
|
||||
'openSSLIV' => null,
|
||||
'search' => implode(' ', [$fileId, $fileName]),
|
||||
'metadata' => ['content_type' => $deviceForFiles->getFileMimeType($fileName)],
|
||||
'metadata' => ['content_type' => $deviceForFiles->getFileMimeType($path)],
|
||||
]);
|
||||
$file = $dbForProject->createDocument('bucket_' . $bucket->getInternalId(), $file);
|
||||
$file = Authorization::skip(fn () => $dbForPlatform->createDocument('bucket_' . $bucket->getInternalId(), $file));
|
||||
|
||||
$deployment->setAttribute('screenshot', $fileId);
|
||||
$dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);
|
||||
|
||||
Reference in New Issue
Block a user