feat(perm): resolvePermissionContext (admin = super-user)

This commit is contained in:
saopig1 committed 2026-05-30 13:17:06 +08:00
1 parent f0c979ce71
commit 7a8666efbb
2 files changed
+37 -1

No files matched your search

+20
View File
@@ -67,3 +67,23 @@ export function createPermissionStore(db: Database.Database): PermissionStore {
},
};
}
export interface PermissionContext {
capabilities: Set<string>;
bots: "all" | Set<string>;
}
export function resolvePermissionContext(
role: "admin" | "member",
userId: string,
store: PermissionStore
): PermissionContext {
if (role === "admin") {
return { capabilities: new Set(CAPABILITIES), bots: "all" };
}
const access = store.getBotAccess(userId);
return {
capabilities: new Set(store.getCapabilities(userId)),
bots: access === "all" ? "all" : new Set(access),
};
}