diff --git a/src/Appwrite/Messaging/Adapter/Realtime.php b/src/Appwrite/Messaging/Adapter/Realtime.php index 0fd124fc9..1bd1245a9 100644 --- a/src/Appwrite/Messaging/Adapter/Realtime.php +++ b/src/Appwrite/Messaging/Adapter/Realtime.php @@ -129,7 +129,7 @@ class Realtime extends Adapter */ public static function send(string $project, array $payload, string $event, array $channels, array $roles, array $options = []): void { - if (empty($channels) || empty($permissions) || empty($project)) return; + if (empty($channels) || empty($roles) || empty($project)) return; $permissionsChanged = array_key_exists('permissionsChanged', $options) && $options['permissionsChanged']; $userId = array_key_exists('userId', $options) ? $options['userId'] : null; diff --git a/tests/e2e/Services/Realtime/RealtimeBase.php b/tests/e2e/Services/Realtime/RealtimeBase.php index 90d2fe677..5407d13a5 100644 --- a/tests/e2e/Services/Realtime/RealtimeBase.php +++ b/tests/e2e/Services/Realtime/RealtimeBase.php @@ -167,9 +167,10 @@ trait RealtimeBase $response = json_decode($client->receive(), true); - $this->assertCount(1, $response['channels']); + $this->assertCount(2, $response['channels']); $this->assertArrayHasKey('timestamp', $response); - $this->assertEquals('account.' . $userId, $response['channels'][0]); + $this->assertContains('account', $response['channels']); + $this->assertContains('account.' . $userId, $response['channels']); $this->assertEquals('account.update.name', $response['event']); $this->assertNotEmpty($response['payload']); @@ -191,9 +192,10 @@ trait RealtimeBase $response = json_decode($client->receive(), true); - $this->assertCount(1, $response['channels']); + $this->assertCount(2, $response['channels']); $this->assertArrayHasKey('timestamp', $response); - $this->assertEquals('account.' . $userId, $response['channels'][0]); + $this->assertContains('account', $response['channels']); + $this->assertContains('account.' . $userId, $response['channels']); $this->assertEquals('account.update.password', $response['event']); $this->assertNotEmpty($response['payload']); @@ -214,9 +216,10 @@ trait RealtimeBase $response = json_decode($client->receive(), true); - $this->assertCount(1, $response['channels']); + $this->assertCount(2, $response['channels']); $this->assertArrayHasKey('timestamp', $response); - $this->assertEquals('account.' . $userId, $response['channels'][0]); + $this->assertContains('account', $response['channels']); + $this->assertContains('account.' . $userId, $response['channels']); $this->assertEquals('account.update.email', $response['event']); $this->assertNotEmpty($response['payload']); @@ -236,9 +239,10 @@ trait RealtimeBase $response = json_decode($client->receive(), true); - $this->assertCount(1, $response['channels']); + $this->assertCount(2, $response['channels']); $this->assertArrayHasKey('timestamp', $response); - $this->assertEquals('account.' . $userId, $response['channels'][0]); + $this->assertContains('account', $response['channels']); + $this->assertContains('account.' . $userId, $response['channels']); $this->assertEquals('account.verification.create', $response['event']); $lastEmail = $this->getLastEmail(); @@ -259,9 +263,10 @@ trait RealtimeBase $response = json_decode($client->receive(), true); - $this->assertCount(1, $response['channels']); + $this->assertCount(2, $response['channels']); $this->assertArrayHasKey('timestamp', $response); - $this->assertEquals('account.' . $userId, $response['channels'][0]); + $this->assertContains('account', $response['channels']); + $this->assertContains('account.' . $userId, $response['channels']); $this->assertEquals('account.verification.update', $response['event']); /** @@ -281,9 +286,10 @@ trait RealtimeBase $response = json_decode($client->receive(), true); - $this->assertCount(1, $response['channels']); + $this->assertCount(2, $response['channels']); $this->assertArrayHasKey('timestamp', $response); - $this->assertEquals('account.' . $userId, $response['channels'][0]); + $this->assertContains('account', $response['channels']); + $this->assertContains('account.' . $userId, $response['channels']); $this->assertEquals('account.update.prefs', $response['event']); $this->assertNotEmpty($response['payload']); @@ -304,9 +310,10 @@ trait RealtimeBase $response = json_decode($client->receive(), true); - $this->assertCount(1, $response['channels']); + $this->assertCount(2, $response['channels']); $this->assertArrayHasKey('timestamp', $response); - $this->assertEquals('account.' . $userId, $response['channels'][0]); + $this->assertContains('account', $response['channels']); + $this->assertContains('account.' . $userId, $response['channels']); $this->assertEquals('account.sessions.create', $response['event']); $this->assertNotEmpty($response['payload']); @@ -322,9 +329,10 @@ trait RealtimeBase $response = json_decode($client->receive(), true); - $this->assertCount(1, $response['channels']); + $this->assertCount(2, $response['channels']); $this->assertArrayHasKey('timestamp', $response); - $this->assertEquals('account.' . $userId, $response['channels'][0]); + $this->assertContains('account', $response['channels']); + $this->assertContains('account.' . $userId, $response['channels']); $this->assertEquals('account.sessions.delete', $response['event']); $this->assertNotEmpty($response['payload']); @@ -345,9 +353,10 @@ trait RealtimeBase $lastEmail = $this->getLastEmail(); $recovery = substr($lastEmail['text'], strpos($lastEmail['text'], '&secret=', 0) + 8, 256); - $this->assertCount(1, $response['channels']); + $this->assertCount(2, $response['channels']); $this->assertArrayHasKey('timestamp', $response); - $this->assertEquals('account.' . $userId, $response['channels'][0]); + $this->assertContains('account', $response['channels']); + $this->assertContains('account.' . $userId, $response['channels']); $this->assertEquals('account.recovery.create', $response['event']); $this->assertNotEmpty($response['payload']); @@ -364,9 +373,10 @@ trait RealtimeBase $response = json_decode($client->receive(), true); - $this->assertCount(1, $response['channels']); + $this->assertCount(2, $response['channels']); $this->assertArrayHasKey('timestamp', $response); - $this->assertEquals('account.' . $userId, $response['channels'][0]); + $this->assertContains('account', $response['channels']); + $this->assertContains('account.' . $userId, $response['channels']); $this->assertEquals('account.recovery.update', $response['event']); $this->assertNotEmpty($response['payload']);