diff --git a/app/controllers/general.php b/app/controllers/general.php index 227745b028..bd49872436 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -30,7 +30,6 @@ use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; use Utopia\Database\Validator\Authorization; -use Utopia\Database\Validator\UID; use Utopia\Domains\Domain; use Utopia\DSN\DSN; use Utopia\Locale\Locale; @@ -1053,14 +1052,13 @@ include_once __DIR__ . '/shared/api/auth.php'; App::get('/v1/ping') ->groups(['api', 'general']) ->desc('Test the connection between the Appwrite and the SDK.') - ->label('scope', 'public') + ->label('scope', 'global') ->label('event', 'projects.[projectId].ping') - ->param('projectId', '', new UID(), 'Project unique ID.') ->inject('response') - ->inject('console') + ->inject('project') ->inject('dbForConsole') ->inject('queueForEvents') - ->action(function (string $projectId, Response $response, Document $project, Database $dbForConsole, Event $queueForEvents) { + ->action(function (Response $response, Document $project, Database $dbForConsole, Event $queueForEvents) { if ($project->isEmpty()) { throw new AppwriteException(AppwriteException::PROJECT_NOT_FOUND); } @@ -1077,8 +1075,7 @@ App::get('/v1/ping') }); $queueForEvents - ->setProject($project) - ->setParam('projectId', $projectId) + ->setParam('projectId', $project->getId()) ->setPayload($response->output($project, Response::MODEL_PROJECT)); $response->text('Pong!'); diff --git a/src/Appwrite/Messaging/Adapter/Realtime.php b/src/Appwrite/Messaging/Adapter/Realtime.php index d0d4a7c725..c437d4d487 100644 --- a/src/Appwrite/Messaging/Adapter/Realtime.php +++ b/src/Appwrite/Messaging/Adapter/Realtime.php @@ -270,6 +270,12 @@ class Realtime extends Adapter $projectId = 'console'; $roles = [Role::team($project->getAttribute('teamId'))->toString()]; break; + case 'projects': + $channels[] = 'console'; + $channels[] = 'projects.' . $parts[1]; + $projectId = 'console'; + $roles = [Role::team($project->getAttribute('teamId'))->toString()]; + break; case 'teams': if ($parts[2] === 'memberships') { $permissionsChanged = $parts[4] ?? false; diff --git a/tests/e2e/General/PingTest.php b/tests/e2e/General/PingTest.php index 96db658cc3..e41bac6736 100644 --- a/tests/e2e/General/PingTest.php +++ b/tests/e2e/General/PingTest.php @@ -38,6 +38,9 @@ class PingTest extends Scope 'x-appwrite-key' => $this->getProject()['apiKey'], ]); + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertEquals('Pong!', $response['body']); + /** * Test for FAILURE */ diff --git a/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php b/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php index 4bb9d8711e..0155d251f2 100644 --- a/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php +++ b/tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php @@ -490,8 +490,6 @@ class RealtimeConsoleClientTest extends Scope $this->assertArrayHasKey('type', $response); $this->assertEquals('connected', $response['type']); - fwrite(STDOUT, 'Project ID: ' . $this->getProject()['$id'] . "\n"); - $pong = $this->client->call(Client::METHOD_GET, '/ping', [ 'origin' => 'http://localhost', 'x-appwrite-project' => $this->getProject()['$id'], @@ -506,7 +504,7 @@ class RealtimeConsoleClientTest extends Scope $this->assertEquals('event', $response['type']); $this->assertNotEmpty($response['data']); $this->assertArrayHasKey('timestamp', $response['data']); - $this->assertCount(1, $response['data']['channels']); + $this->assertCount(2, $response['data']['channels']); $this->assertContains('console', $response['data']['channels']); $this->assertContains("projects.{$this->getProject()['$id']}", $response['data']['channels']); $this->assertContains("projects.{$this->getProject()['$id']}.ping", $response['data']['events']);