coderabbit feedback

This commit is contained in:
Hemachandar
2026-01-08 15:27:02 +05:30
parent ee22d6f5bd
commit df2b1d2113
4 changed files with 12 additions and 7 deletions
-1
View File
@@ -59,7 +59,6 @@ use Utopia\Validator\ArrayList;
use Utopia\Validator\Assoc;
use Utopia\Validator\Boolean;
use Utopia\Validator\Text;
use Utopia\Validator\WhiteList;
App::post('/v1/teams')
->desc('Create team')
+8 -4
View File
@@ -77,9 +77,13 @@ class Role extends Validator
return false;
}
$role = DbRole::parse($value);
$valid = $role->getRole() === Roles::ROLE_PROJECT ? !empty($role->getIdentifier()) && \in_array($role->getDimension(), $this->roles) : \in_array($role->getRole(), $this->roles);
try {
$role = DbRole::parse($value);
$valid = $role->getRole() === Roles::ROLE_PROJECT ? !empty($role->getIdentifier()) && \in_array($role->getDimension(), $this->roles) : \in_array($role->getRole(), $this->roles);
return $valid;
} catch (\Exception $e) {
return false;
}
return $valid;
}
}
}
@@ -62,7 +62,7 @@ class User extends Document
}
foreach ($this->getAttribute('memberships', []) as $node) {
if (!isset($node['confirm']) || !$node['confirm'] || !isset($node['id']) || !isset($node['teamId'])) {
if (!isset($node['confirm']) || !$node['confirm'] || !isset($node['$id']) || !isset($node['teamId'])) {
continue;
}
@@ -74,7 +74,7 @@ class User extends Document
$roles = \array_merge($roles, $projectRoles);
} else {
$roles[] = Role::team($node['teamId'])->toString(); // Add base role for the team
$teamRoles = \array_map(fn ($role) => Role::team($node['teamId'], $role)->toString(), $node['roles'] ?? []);
$teamRoles = \array_map(fn ($role) => Role::team($node['teamId'], $role)->toString(), $node['roles'] ?? []);
$roles = \array_merge($roles, $teamRoles);
}
}
@@ -6,6 +6,8 @@ use Tests\E2E\Client;
use Tests\E2E\Scopes\ProjectConsole;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Role;
class TeamsConsoleClientTest extends Scope
{