core: list all domains for users with PRIV_VIEW_ALL_DOMAIN

This commit is contained in:
undefined committed 2021-05-11 23:38:34 +08:00
1 parent ced60e6567
commit 29965f323b
16 files changed
+53 -26

No files matched your search

+7 -2
View File
@@ -4,13 +4,13 @@ import {
ObjectID, Cursor, FilterQuery, UpdateQuery, OnlyFieldsOfType,
} from 'mongodb';
import {
Pdoc, Ddoc, Drdoc, Tdoc, TrainingDoc, ProblemStatusDoc,
Pdoc, Ddoc, Drdoc, Tdoc, TrainingDoc,
ProblemStatusDoc, User, Content,
} from '../interface';
import { buildProjection } from '../utils';
import { NumberKeys, ArrayKeys, Projection, MaybeArray } from '../typeutils';
import db from '../service/db';
import * as bus from '../service/bus';
import { Content } from '../loader';
type DocID = ObjectID | string | number;
@@ -44,6 +44,11 @@ export interface DocStatusType {
[key: number]: any
}
export async function canView<T extends keyof DocType>(doc: DocType[T], user: User): Promise<boolean> {
if (doc.owner === user._id || doc.maintainers.includes(user._id) || doc.participants.includes(user._id)) return true;
if ()
}
export async function add<T extends keyof DocType, K extends DocType[T]['docId']>(
domainId: string, content: Content, owner: number,
docType: T, docId: K,