mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
removed redundant key
This commit is contained in:
@@ -231,18 +231,19 @@ class Realtime extends MessagingAdapter
|
||||
$payload = $event['data']['payload'] ?? [];
|
||||
foreach ($this->subscriptions[$event['project']][$role][$channel] as $id => $queryMap) {
|
||||
$matchedQueryKeys = [];
|
||||
// for representing a all query subscribed channel
|
||||
if (isset($queryMap[''])) {
|
||||
$matchedQueryKeys[] = '';
|
||||
} else {
|
||||
foreach (array_keys($queryMap) as $queryKey) {
|
||||
$parsed = Query::parseQueries([$queryKey]);
|
||||
if (!empty(RuntimeQuery::filter($parsed, $payload))) {
|
||||
$matchedQueryKeys[] = $queryKey;
|
||||
}
|
||||
$receivers[$id] = $matchedQueryKeys;
|
||||
continue;
|
||||
}
|
||||
foreach (array_keys($queryMap) as $queryKey) {
|
||||
$parsed = Query::parseQueries([$queryKey]);
|
||||
if (!empty(RuntimeQuery::filter($parsed, $payload))) {
|
||||
$matchedQueryKeys[] = $queryKey;
|
||||
}
|
||||
}
|
||||
$receivers[$id] = $matchedQueryKeys;
|
||||
if (!empty($matchedQueryKeys)) {
|
||||
$receivers[$id] = $matchedQueryKeys;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1608,7 +1608,7 @@ class RealtimeCustomClientQueryTest extends Scope
|
||||
Query::equal('category', ['gold']),
|
||||
])->toString();
|
||||
|
||||
// Subscribe with no queries -> should receive all events, queryKeys = ['']
|
||||
// Subscribe with no queries -> should receive all events, queryKeys = []
|
||||
$clientAll = $this->getWebsocket(['documents'], [
|
||||
'origin' => 'http://localhost',
|
||||
'cookie' => 'a_session_' . $projectId . '=' . $session,
|
||||
@@ -1660,13 +1660,13 @@ class RealtimeCustomClientQueryTest extends Scope
|
||||
],
|
||||
]);
|
||||
|
||||
// clientAll: should receive event, queryKeys = ['']
|
||||
// clientAll: should receive event, queryKeys = []
|
||||
$eventAll = json_decode($clientAll->receive(), true);
|
||||
$this->assertEquals('event', $eventAll['type']);
|
||||
$this->assertEquals($docActiveGoldId, $eventAll['data']['payload']['$id']);
|
||||
$this->assertArrayHasKey('queryKeys', $eventAll['data']);
|
||||
$this->assertIsArray($eventAll['data']['queryKeys']);
|
||||
$this->assertEquals([''], $eventAll['data']['queryKeys']);
|
||||
$this->assertCount(0, $eventAll['data']['queryKeys']);
|
||||
|
||||
// clientQ1: should receive event, queryKeys contains queryStatusActive
|
||||
$eventQ1 = json_decode($clientQ1->receive(), true);
|
||||
@@ -1704,13 +1704,13 @@ class RealtimeCustomClientQueryTest extends Scope
|
||||
],
|
||||
]);
|
||||
|
||||
// clientAll: should receive event, queryKeys = ['']
|
||||
// clientAll: should receive event, queryKeys = []
|
||||
$eventAll2 = json_decode($clientAll->receive(), true);
|
||||
$this->assertEquals('event', $eventAll2['type']);
|
||||
$this->assertEquals($docPendingSilverId, $eventAll2['data']['payload']['$id']);
|
||||
$this->assertArrayHasKey('queryKeys', $eventAll2['data']);
|
||||
$this->assertIsArray($eventAll2['data']['queryKeys']);
|
||||
$this->assertEquals([''], $eventAll2['data']['queryKeys']);
|
||||
$this->assertCount(0, $eventAll2['data']['queryKeys']);
|
||||
|
||||
// clientQ1: should NOT receive event (status is pending)
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user