Fix on message db resource fetch

This commit is contained in:
Jake Barnby
2024-04-08 13:43:53 +12:00
parent 048b4f76c8
commit 293d85525c
+7 -4
View File
@@ -629,11 +629,11 @@ $server->onMessage(function (int $connection, string $message) use ($server, $re
try {
$response = new Response(new SwooleResponse());
$projectId = $realtime->connections[$connection]['projectId'];
[$database, $reclaim] = getConsoleDB();
[$database, $reclaimForConsole] = getConsoleDB();
if ($projectId !== 'console') {
$project = Authorization::skip(fn() => $database->getDocument('projects', $projectId));
$database = getProjectDB($project);
[$database, $reclaimForProject] = getProjectDB($project);
} else {
$project = null;
}
@@ -719,8 +719,11 @@ $server->onMessage(function (int $connection, string $message) use ($server, $re
$server->close($connection, $th->getCode());
}
} finally {
if (isset($reclaim)) {
$reclaim();
if (isset($reclaimForConsole)) {
$reclaimForConsole();
}
if (isset($reclaimForProject)) {
$reclaimForProject();
}
}
});