feat: default new roles to @everyone permissions instead of null
This commit is contained in:
@@ -997,14 +997,17 @@ export async function spaceRoutes(app: FastifyInstance): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate permissions string is a valid bigint if provided
|
// Validate permissions string is a valid bigint if provided
|
||||||
let permStr: string | undefined;
|
let permStr: string;
|
||||||
if (permissions !== undefined) {
|
if (permissions !== undefined && permissions !== null) {
|
||||||
try {
|
try {
|
||||||
BigInt(permissions);
|
BigInt(permissions);
|
||||||
permStr = permissions;
|
permStr = permissions;
|
||||||
} catch {
|
} catch {
|
||||||
return reply.code(400).send({ error: 'Invalid permissions value', statusCode: 400 });
|
return reply.code(400).send({ error: 'Invalid permissions value', statusCode: 400 });
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Default to @everyone baseline so new roles start functional
|
||||||
|
permStr = permissionsToString(DEFAULT_EVERYONE_PERMISSIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
const roleId = generateSnowflake();
|
const roleId = generateSnowflake();
|
||||||
@@ -1014,7 +1017,7 @@ export async function spaceRoutes(app: FastifyInstance): Promise<void> {
|
|||||||
name: name || 'new role',
|
name: name || 'new role',
|
||||||
color: color || '#b9bbbe',
|
color: color || '#b9bbbe',
|
||||||
position: 0,
|
position: 0,
|
||||||
permissions: permStr ?? null,
|
permissions: permStr,
|
||||||
createdAt: Date.now(),
|
createdAt: Date.now(),
|
||||||
}).run();
|
}).run();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user