reject and notification on request

This commit is contained in:
Adolfo Reyna
2021-10-29 20:40:59 -07:00
parent bf58c55e97
commit 687be41e3e
3 changed files with 93 additions and 3 deletions

View File

@@ -163,6 +163,31 @@ userDB = (DB) => {
return r;
}
DB.getFollowingGroups = async (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){
ids.push(oId)
}
}
let query = {
isGroup: true,
isCourse: {$ne: true},
_id: {
$in: ids
}
};
let r = await DB.profileCols.find(query).sort({ lastUpdate: -1 })
.toArray().catch((err) => {
console.log(err);
return false;
});
return r;
}
DB.searchGroups = async (queryStr, coursesB = false) => {
let regEx = new RegExp(queryStr, 'i');
let query = queryStr ? {
@@ -242,7 +267,21 @@ userDB = (DB) => {
["pending." + profileid]: ""
}
}
DB.followProfile(profileid, groupid)
DB.followProfile(profileid, groupid);
delete userProfileCache[groupid];
return DB.profileCols.updateOne({_id}, update).catch((err)=>{
console.log(err);
return false;
});
}
DB.rejectGroupJoinReq = async (profileid, groupid) => {
const _id = DB.ObjectID(groupid);
let update = {
$unset:{
["pending." + profileid]: ""
}
}
delete userProfileCache[groupid];
return DB.profileCols.updateOne({_id}, update).catch((err)=>{
console.log(err);