Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify #4354

Merged
merged 1 commit into from
Jan 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions server/middleware/src/spaceSecurity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,13 @@ export class SpaceSecurityMiddleware extends BaseMiddleware implements Middlewar

private async initDomains (ctx: MeasureContext): Promise<void> {
const classesPerDomain: Record<string, Ref<Class<Doc>>[]> = {}
const skip = new Set<Ref<Class<Doc>>>()
const classes = this.storage.hierarchy.getDescendants(core.class.Doc)
for (const _class of classes) {
if (skip.has(_class)) continue
try {
const parent = this.storage.hierarchy.getParentClass(_class)
skip.add(parent)
const domain = this.storage.hierarchy.findDomain(parent)
if (domain === undefined) continue
classesPerDomain[domain] = classesPerDomain[domain] ?? []
classesPerDomain[domain].push(parent)
this.storage.hierarchy.getDescendants(parent).forEach((p) => skip.add(p))
} catch {}
const clazz = this.storage.hierarchy.getClass(_class)
if (clazz.domain === undefined) continue
const domain = clazz.domain
classesPerDomain[domain] = classesPerDomain[domain] ?? []
classesPerDomain[domain].push(_class)
}
for (const domain in classesPerDomain) {
for (const _class of classesPerDomain[domain]) {
Expand Down