reject and notification on request
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user