add: backported channels.

This commit is contained in:
Darshan
2025-05-06 12:52:05 +05:30
parent a0ffcd54dc
commit d70d001f5a
2 changed files with 12 additions and 6 deletions
@@ -311,10 +311,16 @@ class Realtime extends Adapter
throw new \Exception('Table needs to be passed to Realtime for Row events in the Database.');
}
// 1.7.x
$channels[] = 'rows';
$channels[] = 'databases.' . $database->getId() . '.tables.' . $payload->getAttribute('$tableId') . '.rows';
$channels[] = 'databases.' . $database->getId() . '.tables.' . $payload->getAttribute('$tableId') . '.rows.' . $payload->getId();
// 1.6.x
$channels[] = 'documents';
$channels[] = 'databases.' . $database->getId() . '.collections.' . $payload->getAttribute('$tableId') . '.documents';
$channels[] = 'databases.' . $database->getId() . '.collections.' . $payload->getAttribute('$tableId') . '.documents.' . $payload->getId();
$roles = $table->getAttribute('documentSecurity', false)
? \array_merge($table->getRead(), $payload->getRead())
: $table->getRead();
@@ -769,7 +769,7 @@ class RealtimeCustomClientTest extends Scope
$this->assertEquals('event', $response['type']);
$this->assertNotEmpty($response['data']);
$this->assertArrayHasKey('timestamp', $response['data']);
$this->assertCount(3, $response['data']['channels']);
$this->assertCount(6, $response['data']['channels']); // includes old and new channels
$this->assertContains('rows', $response['data']['channels']);
$this->assertContains('databases.' . $databaseId . '.tables.' . $actorsId . '.rows.' . $documentId, $response['data']['channels']);
$this->assertContains('databases.' . $databaseId . '.tables.' . $actorsId . '.rows', $response['data']['channels']);
@@ -813,7 +813,7 @@ class RealtimeCustomClientTest extends Scope
$this->assertEquals('event', $response['type']);
$this->assertNotEmpty($response['data']);
$this->assertArrayHasKey('timestamp', $response['data']);
$this->assertCount(3, $response['data']['channels']);
$this->assertCount(6, $response['data']['channels']); // includes old and new channels
$this->assertContains('rows', $response['data']['channels']);
$this->assertContains("databases.{$databaseId}.tables.{$actorsId}.rows.{$documentId}", $response['data']['channels']);
$this->assertContains("databases.{$databaseId}.tables.{$actorsId}.rows", $response['data']['channels']);
@@ -867,7 +867,7 @@ class RealtimeCustomClientTest extends Scope
$this->assertEquals('event', $response['type']);
$this->assertNotEmpty($response['data']);
$this->assertArrayHasKey('timestamp', $response['data']);
$this->assertCount(3, $response['data']['channels']);
$this->assertCount(6, $response['data']['channels']); // includes old and new channels
$this->assertContains('rows', $response['data']['channels']);
$this->assertContains("databases.{$databaseId}.tables.{$actorsId}.rows.{$documentId}", $response['data']['channels']);
$this->assertContains("databases.{$databaseId}.tables.{$actorsId}.rows", $response['data']['channels']);
@@ -987,7 +987,7 @@ class RealtimeCustomClientTest extends Scope
$this->assertEquals('event', $response['type']);
$this->assertNotEmpty($response['data']);
$this->assertArrayHasKey('timestamp', $response['data']);
$this->assertCount(3, $response['data']['channels']);
$this->assertCount(6, $response['data']['channels']); // includes old and new channels
$this->assertContains('rows', $response['data']['channels']);
$this->assertContains("databases.{$databaseId}.tables.{$actorsId}.rows.{$documentId}", $response['data']['channels']);
$this->assertContains("databases.{$databaseId}.tables.{$actorsId}.rows", $response['data']['channels']);
@@ -1026,7 +1026,7 @@ class RealtimeCustomClientTest extends Scope
$this->assertEquals('event', $response['type']);
$this->assertNotEmpty($response['data']);
$this->assertArrayHasKey('timestamp', $response['data']);
$this->assertCount(3, $response['data']['channels']);
$this->assertCount(6, $response['data']['channels']); // includes old and new channels
$this->assertContains('rows', $response['data']['channels']);
$this->assertContains("databases.{$databaseId}.tables.{$actorsId}.rows.{$documentId}", $response['data']['channels']);
$this->assertContains("databases.{$databaseId}.tables.{$actorsId}.rows", $response['data']['channels']);
@@ -1076,7 +1076,7 @@ class RealtimeCustomClientTest extends Scope
$this->assertEquals('event', $response['type']);
$this->assertNotEmpty($response['data']);
$this->assertArrayHasKey('timestamp', $response['data']);
$this->assertCount(3, $response['data']['channels']);
$this->assertCount(6, $response['data']['channels']); // includes old and new channels
$this->assertContains('rows', $response['data']['channels']);
$this->assertContains("databases.{$databaseId}.tables.{$actorsId}.rows.{$documentId}", $response['data']['channels']);
$this->assertContains("databases.{$databaseId}.tables.{$actorsId}.rows", $response['data']['channels']);