mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core&ui: implement domain leave and kick
This commit is contained in:
13 files changed
+64
-28
No files matched your search
@@ -135,7 +135,7 @@ class DomainModel {
|
||||
@ArgMethod
|
||||
static async setUserRole(domainId: string, uid: MaybeArray<number>, role: string, autojoin = false) {
|
||||
const update = { $set: { role, ...(autojoin ? { join: true } : {}) } };
|
||||
if (!(uid instanceof Array)) {
|
||||
if (!(Array.isArray(uid))) {
|
||||
const res = await collUser.findOneAndUpdate(
|
||||
{ domainId, uid },
|
||||
update,
|
||||
@@ -152,6 +152,15 @@ class DomainModel {
|
||||
return await collUser.updateMany({ domainId, uid: { $in: uid } }, update, { upsert: true });
|
||||
}
|
||||
|
||||
static async setJoin(domainId: string, uid: MaybeArray<number>, join: boolean) {
|
||||
if (!(Array.isArray(uid))) {
|
||||
await DomainModel.updateUserInDomain(domainId, uid, { $set: { join } });
|
||||
return;
|
||||
}
|
||||
await collUser.updateMany({ domainId, uid: { $in: uid } }, { $set: { join } });
|
||||
deleteUserCache(domainId);
|
||||
}
|
||||
|
||||
static async getRoles(domainId: string, count?: boolean): Promise<any[]>;
|
||||
static async getRoles(domain: DomainDoc, count?: boolean): Promise<any[]>;
|
||||
@ArgMethod
|
||||
|
||||
Reference in new issue
Block a user