fix(realtime): unsubscribe before resubscribing on permission change

Unsubcribe to remove subscriptions related to the old permissions.
This commit is contained in:
Steven Nguyen
2024-07-19 00:06:14 +00:00
committed by GitHub
parent 5aa944ee82
commit 80769a0b65
+3 -1
View File
@@ -380,8 +380,10 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats,
$user = $database->getDocument('users', $userId);
$roles = Auth::getRoles($user);
$channels = $realtime->connections[$connection]['channels'];
$realtime->subscribe($projectId, $connection, $roles, $realtime->connections[$connection]['channels']);
$realtime->unsubscribe($connection);
$realtime->subscribe($projectId, $connection, $roles, $channels);
$register->get('pools')->reclaim();
}