diff --git a/src/pages/api/make_user.ts b/src/pages/api/make_user.ts index 48baec94..43fa90b5 100644 --- a/src/pages/api/make_user.ts +++ b/src/pages/api/make_user.ts @@ -42,19 +42,17 @@ async function post(req: NextApiRequest, res: NextApiResponse) { const corporateCorporate = await getUserCorporate(maker.id); - const {email, passport_id, password, type, groupName, groupID, expiryDate, corporate} = req.body as { + const {email, passport_id, password, type, groupID, expiryDate, corporate} = req.body as { email: string; password?: string; passport_id: string; type: string; - groupName?: string; groupID?: string; corporate?: string; expiryDate: null | Date; }; // cleaning data delete req.body.passport_id; - delete req.body.groupName; delete req.body.groupID; delete req.body.expiryDate; delete req.body.password; @@ -202,32 +200,6 @@ async function post(req: NextApiRequest, res: NextApiResponse) { } } - if (typeof groupName === "string" && groupName.trim().length > 0) { - const q = query(collection(db, "groups"), where("admin", "==", maker.id), where("name", "==", groupName.trim()), limit(1)); - const snapshot = await getDocs(q); - - if (snapshot.empty) { - const values = { - id: v4(), - admin: maker.id, - name: groupName.trim(), - participants: [userId], - disableEditing: false, - }; - - await setDoc(doc(db, "groups", values.id), values); - } else { - const doc = snapshot.docs[0]; - const participants: string[] = doc.get("participants"); - - if (!participants.includes(userId)) { - updateDoc(doc.ref, { - participants: [...participants, userId], - }); - } - } - } - if (!!groupID) { const groupSnapshot = await getDoc(doc(db, "groups", groupID)); await setDoc(groupSnapshot.ref, {participants: [...groupSnapshot.data()!.participants, userId]}, {merge: true});