Updated the groups and users
This commit is contained in:
@@ -9,7 +9,7 @@ import {createUserWithEmailAndPassword, getAuth} from "firebase/auth";
|
||||
import ShortUniqueId from "short-unique-id";
|
||||
import {getUserCorporate, getUserGroups} from "@/utils/groups.be";
|
||||
import {uniq} from "lodash";
|
||||
import {getUser} from "@/utils/users.be";
|
||||
import {getSpecificUsers, getUser} from "@/utils/users.be";
|
||||
|
||||
const DEFAULT_DESIRED_LEVELS = {
|
||||
reading: 9,
|
||||
@@ -32,9 +32,10 @@ export default withIronSessionApiRoute(handler, sessionOptions);
|
||||
|
||||
const getUsersOfType = async (admin: string, type: Type) => {
|
||||
const groups = await getUserGroups(admin);
|
||||
const users = await Promise.all(uniq(groups.flatMap((x) => x.participants)).map(getUser));
|
||||
const participants = groups.flatMap((x) => x.participants);
|
||||
const users = await getSpecificUsers(participants);
|
||||
|
||||
return users.filter((x) => x.type === type).map((x) => x.id);
|
||||
return users.filter((x) => x?.type === type).map((x) => x?.id);
|
||||
};
|
||||
|
||||
async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
|
||||
Reference in New Issue
Block a user