temporary fix invalid ids

This commit is contained in:
aeroreyna
2022-03-19 14:44:56 -07:00
parent ec2d16f3db
commit f7dd5365c8

View File

@@ -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);