MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / getDomainUser

Method getDomainUser

packages/hydrooj/src/model/domain.ts:233–245  ·  view source on GitHub ↗
(domainId: string, udoc: DomainUserArg)

Source from the content-addressed store, hash-verified

231 }
232
233 static async getDomainUser(domainId: string, udoc: DomainUserArg) {
234 let dudoc = await collUser.findOne({ domainId, uid: udoc._id });
235 dudoc ||= { domainId, uid: udoc._id };
236 if (!(udoc.priv & PRIV.PRIV_USER_PROFILE)) dudoc.role = 'guest';
237 if (!dudoc.join && !(udoc.priv & PRIV.PRIV_VIEW_ALL_DOMAIN)) dudoc.role = 'guest';
238 if (udoc.priv & PRIV.PRIV_MANAGE_ALL_DOMAIN) dudoc.role = 'root';
239 dudoc.role ||= 'default';
240 const ddoc = await DomainModel.get(domainId);
241 dudoc.perm = ddoc?.roles[dudoc.role]
242 ? BigInt(ddoc?.roles[dudoc.role])
243 : BUILTIN_ROLES[dudoc.role];
244 return dudoc;
245 }
246
247 static getDomainUserMulti(domainId: string, uids: number[]) {
248 return collUser.find({ domainId, uid: { $in: uids } });

Callers 4

incUserInDomainMethod · 0.80
getByIdMethod · 0.80
getByUnameMethod · 0.80
getByEmailMethod · 0.80

Calls 1

getMethod · 0.45

Tested by

no test coverage detected