From f7dd5365c8060443a619a2ec46a601de1f453e0d Mon Sep 17 00:00:00 2001 From: aeroreyna Date: Sat, 19 Mar 2022 14:44:56 -0700 Subject: [PATCH] temporary fix invalid ids --- dbTools/post.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dbTools/post.js b/dbTools/post.js index ca43a4e..18f60be 100644 --- a/dbTools/post.js +++ b/dbTools/post.js @@ -111,7 +111,7 @@ postDB = (DB)=>{ DB.getPosts = async (profileId, viewerProfileId) => { const profile = await DB.getProfile(viewerProfileId); let query = {}; - if(profileId) { + if(profileId && DB.ObjectID.isValid(profileId)) { const id = DB.ObjectID(profileId); query = { $or: [ @@ -119,6 +119,8 @@ postDB = (DB)=>{ {toProfile: id} ] }; + } else { + if(profileId) return []; } return DB.postCols.find(query).sort({_id: -1}).limit(20).toArray().then(async (posts)=>{ return await filterPrivateGroups(posts, profile);