mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge branch 'main' into fix/vcs-disconnect-on-revoked-installation
This commit is contained in:
7 files changed
+68
-93
No files matched your search
@@ -299,7 +299,8 @@ Http::init()
|
||||
elseif (($project->getId() === 'console' && ! $team->isEmpty() && ! $user->isEmpty()) || ($project->getId() !== 'console' && ! $user->isEmpty() && $mode === APP_MODE_ADMIN)) {
|
||||
$teamId = $team->getId();
|
||||
$adminRoles = [];
|
||||
$memberships = $user->getAttribute('memberships', []);
|
||||
$membershipSource = !$impersonatorUser->isEmpty() ? $targetUser : $user;
|
||||
$memberships = $membershipSource->getAttribute('memberships', []);
|
||||
foreach ($memberships as $membership) {
|
||||
if ($membership->getAttribute('confirm', false) === true && $membership->getAttribute('teamId') === $teamId) {
|
||||
$adminRoles = $membership->getAttribute('roles', []);
|
||||
@@ -368,6 +369,17 @@ Http::init()
|
||||
$authorization->addRole($authRole);
|
||||
}
|
||||
|
||||
$isAdminProjectRequest = ! $user->isEmpty()
|
||||
&& $project->getId() !== 'console'
|
||||
&& $mode === APP_MODE_ADMIN;
|
||||
$isOAuthAdminKey = ! empty($apiKey)
|
||||
&& $apiKey->getType() === API_KEY_OAUTH2
|
||||
&& $apiKey->getRole() === User::ROLE_OWNER;
|
||||
|
||||
if ($isAdminProjectRequest && $isOAuthAdminKey) {
|
||||
$authorization->setDefaultStatus(false);
|
||||
}
|
||||
|
||||
if (!$impersonatorUser->isEmpty() && !$targetUser->isEmpty()) {
|
||||
$dbForProject->setMetadata('user', $targetUser->getId());
|
||||
$dbForPlatform->setMetadata('user', $targetUser->getId());
|
||||
@@ -378,7 +390,7 @@ Http::init()
|
||||
* But, for actions on resources (sites, functions, etc.) in a non-console project, we explicitly check
|
||||
* whether the admin user has necessary permission on the project (sites, functions, etc. don't have permissions associated to them).
|
||||
*/
|
||||
if (empty($apiKey) && ! $user->isEmpty() && $project->getId() !== 'console' && $mode === APP_MODE_ADMIN) {
|
||||
if ($isAdminProjectRequest && (empty($apiKey) || $isOAuthAdminKey)) {
|
||||
$input = new Input(Database::PERMISSION_READ, $project->getPermissionsByType(Database::PERMISSION_READ));
|
||||
$initialStatus = $authorization->getStatus();
|
||||
$authorization->enable();
|
||||
|
||||
@@ -288,6 +288,7 @@ const API_KEY_STANDARD = 'standard';
|
||||
const API_KEY_EPHEMERAL = 'ephemeral';
|
||||
const API_KEY_ORGANIZATION = 'organization';
|
||||
const API_KEY_ACCOUNT = 'account';
|
||||
const API_KEY_OAUTH2 = 'oauth2';
|
||||
|
||||
// Realtime
|
||||
const CONSOLE_TAIL_CHANNEL_PREFIX = 'console.tail';
|
||||
|
||||
Generated
+6
-6
@@ -3736,16 +3736,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/detector",
|
||||
"version": "0.2.5",
|
||||
"version": "0.2.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/detector.git",
|
||||
"reference": "20f7e2ea8084176fae88a473f82f410281978a3b"
|
||||
"reference": "a564381108518ce6d18b6ab441f1448bd8355afd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/detector/zipball/20f7e2ea8084176fae88a473f82f410281978a3b",
|
||||
"reference": "20f7e2ea8084176fae88a473f82f410281978a3b",
|
||||
"url": "https://api.github.com/repos/utopia-php/detector/zipball/a564381108518ce6d18b6ab441f1448bd8355afd",
|
||||
"reference": "a564381108518ce6d18b6ab441f1448bd8355afd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3775,9 +3775,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/detector/issues",
|
||||
"source": "https://github.com/utopia-php/detector/tree/0.2.5"
|
||||
"source": "https://github.com/utopia-php/detector/tree/0.2.4"
|
||||
},
|
||||
"time": "2026-06-17T08:16:37+00:00"
|
||||
"time": "2026-02-17T11:26:34+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/di",
|
||||
|
||||
+9
-34
@@ -152,6 +152,7 @@ class Create extends Action
|
||||
$contentResponse = $github->getRepositoryContent($owner, $repositoryName, \rtrim($providerRootDirectory, '/') . '/package.json');
|
||||
$packages = $contentResponse['content'] ?? '';
|
||||
} catch (FileNotFound $e) {
|
||||
// Continue detection without package.json
|
||||
}
|
||||
|
||||
$output = new Document([
|
||||
@@ -159,7 +160,6 @@ class Create extends Action
|
||||
'installCommand' => '',
|
||||
'buildCommand' => '',
|
||||
'outputDirectory' => '',
|
||||
'adapter' => '',
|
||||
]);
|
||||
|
||||
$detector = new Framework($packager);
|
||||
@@ -190,43 +190,19 @@ class Create extends Action
|
||||
$output->setAttribute('installCommand', $framework->getInstallCommand());
|
||||
$output->setAttribute('buildCommand', $framework->getBuildCommand());
|
||||
$output->setAttribute('outputDirectory', $framework->getOutputDirectory());
|
||||
$frameworkName = $framework->getName();
|
||||
|
||||
$configContent = '';
|
||||
foreach ($framework->getConfigFiles() as $configFile) {
|
||||
if (!\in_array($configFile, $files, true)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
$configPath = \rtrim($providerRootDirectory, '/') . '/' . $configFile;
|
||||
$configResponse = $github->getRepositoryContent($owner, $repositoryName, $configPath);
|
||||
$configContent = $configResponse['content'] ?? '';
|
||||
if (!empty($configContent)) {
|
||||
break;
|
||||
}
|
||||
} catch (FileNotFound $e) {
|
||||
}
|
||||
}
|
||||
|
||||
$detectedAdapter = !empty($configContent) ? $framework->getAdapter($configContent) : '';
|
||||
$framework = $framework->getName();
|
||||
} else {
|
||||
$frameworkName = 'other';
|
||||
$detectedAdapter = '';
|
||||
$framework = 'other';
|
||||
$output->setAttribute('installCommand', '');
|
||||
$output->setAttribute('buildCommand', '');
|
||||
$output->setAttribute('outputDirectory', '');
|
||||
}
|
||||
|
||||
$frameworks = Config::getParam('frameworks');
|
||||
if (!\in_array($frameworkName, \array_keys($frameworks), true)) {
|
||||
$frameworkName = 'other';
|
||||
}
|
||||
$output->setAttribute('framework', $frameworkName);
|
||||
|
||||
$frameworkConfig = $frameworks[$frameworkName] ?? [];
|
||||
if (!empty($frameworkConfig['adapters'])) {
|
||||
$adapter = (!empty($detectedAdapter) && isset($frameworkConfig['adapters'][$detectedAdapter]))
|
||||
? $detectedAdapter
|
||||
: \array_key_first($frameworkConfig['adapters']);
|
||||
$output->setAttribute('adapter', $adapter);
|
||||
if (!\in_array($framework, \array_keys($frameworks), true)) {
|
||||
$framework = 'other';
|
||||
}
|
||||
$output->setAttribute('framework', $framework);
|
||||
} else {
|
||||
$output = new Document([
|
||||
'runtime' => '',
|
||||
@@ -337,5 +313,4 @@ class Create extends Action
|
||||
|
||||
$response->dynamic($output, $type === 'framework' ? Response::MODEL_DETECTION_FRAMEWORK : Response::MODEL_DETECTION_RUNTIME);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,12 +38,6 @@ class DetectionFramework extends Detection
|
||||
'description' => 'Site Output Directory',
|
||||
'default' => '',
|
||||
'example' => 'dist',
|
||||
])
|
||||
->addRule('adapter', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Site Adapter',
|
||||
'default' => '',
|
||||
'example' => 'ssr',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -221,27 +221,33 @@ trait TemplatesBase
|
||||
{
|
||||
$this->ensureSMTPEnabled();
|
||||
|
||||
$runId = \uniqid();
|
||||
$firstSubject = "First subject {$runId}";
|
||||
$firstBody = "First body {$runId}";
|
||||
$secondSubject = "Second subject {$runId}";
|
||||
$secondBody = "Second body {$runId}";
|
||||
|
||||
$first = $this->updateEmailTemplate(
|
||||
templateId: 'otpSession',
|
||||
locale: 'en',
|
||||
subject: 'First subject',
|
||||
message: 'First body',
|
||||
subject: $firstSubject,
|
||||
message: $firstBody,
|
||||
);
|
||||
$this->assertSame(200, $first['headers']['status-code']);
|
||||
|
||||
$second = $this->updateEmailTemplate(
|
||||
templateId: 'otpSession',
|
||||
locale: 'en',
|
||||
subject: 'Second subject',
|
||||
message: 'Second body',
|
||||
subject: $secondSubject,
|
||||
message: $secondBody,
|
||||
);
|
||||
$this->assertSame(200, $second['headers']['status-code']);
|
||||
$this->assertSame('Second subject', $second['body']['subject']);
|
||||
$this->assertSame('Second body', $second['body']['message']);
|
||||
$this->assertSame($secondSubject, $second['body']['subject']);
|
||||
$this->assertSame($secondBody, $second['body']['message']);
|
||||
|
||||
$get = $this->getEmailTemplate('otpSession', 'en');
|
||||
$this->assertSame('Second subject', $get['body']['subject']);
|
||||
$this->assertSame('Second body', $get['body']['message']);
|
||||
$this->assertSame($secondSubject, $get['body']['subject']);
|
||||
$this->assertSame($secondBody, $get['body']['message']);
|
||||
}
|
||||
|
||||
public function testUpdateEmailTemplatePartialAfterSeed(): void
|
||||
@@ -281,32 +287,36 @@ trait TemplatesBase
|
||||
{
|
||||
$this->ensureSMTPEnabled();
|
||||
|
||||
$runId = \uniqid();
|
||||
$enSubject = "English subject {$runId}";
|
||||
$frSubject = "Sujet francais {$runId}";
|
||||
|
||||
$enUpdate = $this->updateEmailTemplate(
|
||||
templateId: 'invitation',
|
||||
locale: 'en',
|
||||
subject: 'English subject',
|
||||
subject: $enSubject,
|
||||
message: 'English body',
|
||||
);
|
||||
$this->assertSame(200, $enUpdate['headers']['status-code']);
|
||||
$this->assertSame('en', $enUpdate['body']['locale']);
|
||||
$this->assertSame('English subject', $enUpdate['body']['subject']);
|
||||
$this->assertSame($enSubject, $enUpdate['body']['subject']);
|
||||
|
||||
$frUpdate = $this->updateEmailTemplate(
|
||||
templateId: 'invitation',
|
||||
locale: 'fr',
|
||||
subject: 'Sujet francais',
|
||||
subject: $frSubject,
|
||||
message: 'Corps francais',
|
||||
);
|
||||
$this->assertSame(200, $frUpdate['headers']['status-code']);
|
||||
$this->assertSame('fr', $frUpdate['body']['locale']);
|
||||
$this->assertSame('Sujet francais', $frUpdate['body']['subject']);
|
||||
$this->assertSame($frSubject, $frUpdate['body']['subject']);
|
||||
|
||||
// Locales remain independent.
|
||||
$enGet = $this->getEmailTemplate('invitation', 'en');
|
||||
$this->assertSame('English subject', $enGet['body']['subject']);
|
||||
$this->assertSame($enSubject, $enGet['body']['subject']);
|
||||
|
||||
$frGet = $this->getEmailTemplate('invitation', 'fr');
|
||||
$this->assertSame('Sujet francais', $frGet['body']['subject']);
|
||||
$this->assertSame($frSubject, $frGet['body']['subject']);
|
||||
}
|
||||
|
||||
public function testUpdateEmailTemplateResponseModel(): void
|
||||
@@ -729,19 +739,21 @@ trait TemplatesBase
|
||||
$response = $this->listEmailTemplates();
|
||||
$this->assertSame(200, $response['headers']['status-code']);
|
||||
|
||||
$foundEn = false;
|
||||
$foundFr = false;
|
||||
foreach ($response['body']['templates'] as $template) {
|
||||
if ($template['templateId'] === 'recovery' && $template['locale'] === 'en' && $template['subject'] === $enSubject) {
|
||||
$foundEn = true;
|
||||
}
|
||||
if ($template['templateId'] === 'recovery' && $template['locale'] === 'fr' && $template['subject'] === $frSubject) {
|
||||
$foundFr = true;
|
||||
}
|
||||
}
|
||||
$foundEn = \array_filter(
|
||||
$response['body']['templates'],
|
||||
fn ($template) => $template['templateId'] === 'recovery'
|
||||
&& $template['locale'] === 'en'
|
||||
&& $template['subject'] === $enSubject
|
||||
);
|
||||
$foundFr = \array_filter(
|
||||
$response['body']['templates'],
|
||||
fn ($template) => $template['templateId'] === 'recovery'
|
||||
&& $template['locale'] === 'fr'
|
||||
&& $template['subject'] === $frSubject
|
||||
);
|
||||
|
||||
$this->assertTrue($foundEn, 'recovery/en must appear in the list');
|
||||
$this->assertTrue($foundFr, 'recovery/fr must appear in the list');
|
||||
$this->assertNotEmpty($foundEn, 'recovery/en must appear in the list');
|
||||
$this->assertNotEmpty($foundFr, 'recovery/fr must appear in the list');
|
||||
}
|
||||
|
||||
public function testListEmailTemplatesUpdateDoesNotDuplicate(): void
|
||||
|
||||
@@ -185,7 +185,6 @@ final class VCSConsoleClientTest extends Scope
|
||||
$this->assertEquals('npm install', $framework['body']['installCommand']);
|
||||
$this->assertEquals('npm run build', $framework['body']['buildCommand']);
|
||||
$this->assertEquals('./build', $framework['body']['outputDirectory']);
|
||||
$this->assertEquals('ssr', $framework['body']['adapter']);
|
||||
|
||||
$framework = $this->client->call(Client::METHOD_POST, '/vcs/github/installations/' . $installationId . '/detections', array_merge([
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
@@ -201,7 +200,6 @@ final class VCSConsoleClientTest extends Scope
|
||||
$this->assertEquals('npm install', $framework['body']['installCommand']);
|
||||
$this->assertEquals('npm run build', $framework['body']['buildCommand']);
|
||||
$this->assertEquals('./dist', $framework['body']['outputDirectory']);
|
||||
$this->assertEquals('ssr', $framework['body']['adapter']);
|
||||
|
||||
$framework = $this->client->call(Client::METHOD_POST, '/vcs/github/installations/' . $installationId . '/detections', array_merge([
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
@@ -217,23 +215,6 @@ final class VCSConsoleClientTest extends Scope
|
||||
$this->assertEquals('npm install', $framework['body']['installCommand']);
|
||||
$this->assertEquals('npm run build', $framework['body']['buildCommand']);
|
||||
$this->assertEquals('./build', $framework['body']['outputDirectory']);
|
||||
$this->assertEquals('ssr', $framework['body']['adapter']);
|
||||
|
||||
$framework = $this->client->call(Client::METHOD_POST, '/vcs/github/installations/' . $installationId . '/detections', array_merge([
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'content-type' => 'application/json',
|
||||
], $this->getHeaders()), [
|
||||
'providerRepositoryId' => $this->providerRepositoryId4,
|
||||
'type' => 'framework',
|
||||
'providerRootDirectory' => 'tanstack-start/starter'
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $framework['headers']['status-code']);
|
||||
$this->assertEquals('tanstack-start', $framework['body']['framework']);
|
||||
$this->assertEquals('npm install', $framework['body']['installCommand']);
|
||||
$this->assertEquals('npm run build', $framework['body']['buildCommand']);
|
||||
$this->assertEquals('./.output', $framework['body']['outputDirectory']);
|
||||
$this->assertEquals('ssr', $framework['body']['adapter']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
|
||||
Reference in new issue
Block a user