fix(mqtt): resolve getProjectDB via the container in the SUBSCRIBE authorizer

The DI refactor moved the broker's DB/cache resolvers onto the container but
left the authorizer closure calling the removed global getProjectDB(), so every
SUBSCRIBE threw "Call to undefined function getProjectDB()" before the SUBACK
(CONNECT was unaffected as it only uses the authenticator).
This commit is contained in:
ArnabChatterjee20k committed 2026-09-17 21:41:29 +05:30
1 parent 72e5465d3b
commit 8d5e92e288
1 file changed
+4 -3
+4 -3
View File
@@ -108,8 +108,8 @@ return function (Container $container): void {
};
}, []);
$container->set('authorizer', function () use ($getProject): callable {
return function (array $identity, string $topic) use ($getProject): bool {
$container->set('authorizer', function () use ($getProject, $container): callable {
return function (array $identity, string $topic) use ($getProject, $container): bool {
$userId = $identity['userId'] ?? '';
$projectId = $identity['projectId'] ?? '';
if ($userId === '' || $projectId === '') {
@@ -123,7 +123,8 @@ return function (Container $container): void {
return false;
}
$dbForProject = getProjectDB($project);
$getProjectDB = $container->get('getProjectDB');
$dbForProject = $getProjectDB($project);
$dbForProject->setAuthorization($authorization);
$user = $authorization->skip(fn () => $dbForProject->getDocument('users', $userId));