diff --git a/dbTools/profile.js b/dbTools/profile.js index ab0ad23..45bdfde 100644 --- a/dbTools/profile.js +++ b/dbTools/profile.js @@ -286,13 +286,17 @@ userDB = (DB) => { } DB.getFollowingGroups = async (profileid) => { - const profile = await DB.getProfile(profileId); + const profile = await DB.getProfile(profileid); let ids = []; for(id in profile.following){ - let oId = DB.ObjectID(id); - let checkProfile = await DB.getProfileCache(oId) - if(checkProfile && checkProfile.isGroup && !checkProfile.isChat){ - ids.push(oId) + try{ + let oId = DB.ObjectID(profile.following[id]); + let checkProfile = await DB.getProfileCache(oId) + if(checkProfile && checkProfile.isGroup && !checkProfile.isChat){ + ids.push(oId) + } + }catch{ + } } let query = { diff --git a/routes/profile.js b/routes/profile.js index 322abbd..89f1357 100644 --- a/routes/profile.js +++ b/routes/profile.js @@ -96,7 +96,8 @@ DB.getDB.then((DB)=>{ }); router.get("/groups/following", async (req, res) => { - let groups = await DB.getFollowingGroups(); + const profileId = getProfileId(req); + let groups = await DB.getFollowingGroups(profileId); return res.json({ status: "ok", groups