mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
fix: realtime event
This commit is contained in:
@@ -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!');
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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']);
|
||||
|
||||
Reference in New Issue
Block a user