reject and notification on request
This commit is contained in:
@@ -89,6 +89,14 @@ DB.getDB.then((DB)=>{
|
||||
});
|
||||
});
|
||||
|
||||
router.get("/groups/following", async (req, res) => {
|
||||
let groups = await DB.getFollowingGroups();
|
||||
return res.json({
|
||||
status: "ok",
|
||||
groups
|
||||
});
|
||||
});
|
||||
|
||||
router.post("/groups", async (req, res) => {
|
||||
let profile = {
|
||||
userid: getUserId(req),
|
||||
@@ -124,6 +132,26 @@ DB.getDB.then((DB)=>{
|
||||
const profileAcepted = DB.ObjectID(req.body.profileid);
|
||||
DB.acceptGroupJoinReq(profileAcepted, groupidBody || groupid);
|
||||
//Add Notification to accepted user
|
||||
//Notifications.yourGroupHasARequest(profileAcepted, groupidBody || groupid)
|
||||
return res.json({
|
||||
status: "ok"
|
||||
});
|
||||
});
|
||||
|
||||
router.post("/groups/reject", async (req, res) => {
|
||||
//This function should be called to accept the join request
|
||||
//of an user that attempt to join a private group.
|
||||
const groupid = getProfileId(req); //It needs to have this profile context
|
||||
const groupidBody = req.body.groupid ? DB.ObjectID(req.body.groupid) : undefined;
|
||||
if(groupidBody && groupid != groupidBody && !DB.isOwnerOfGroup(groupid, groupidBody)){
|
||||
return res.json({
|
||||
status: "Only group owner can reject new subscribers"
|
||||
});
|
||||
}
|
||||
const profileAcepted = DB.ObjectID(req.body.profileid);
|
||||
DB.rejectGroupJoinReq(profileAcepted, groupidBody || groupid);
|
||||
//Add Notification to rejected user
|
||||
//Notifications.yourGroupHasARequest(profileAcepted, groupidBody || groupid)
|
||||
return res.json({
|
||||
status: "ok"
|
||||
});
|
||||
@@ -154,6 +182,7 @@ DB.getDB.then((DB)=>{
|
||||
const isPrivate = await DB.isGroupPrivate(groupid);
|
||||
DB.subscribeToGroup(profileid, groupid, isPrivate);
|
||||
//Add notification to group owner
|
||||
if(isPrivate) Notifications.yourGroupHasARequest(profileid, groupid)
|
||||
return res.json({
|
||||
status: "ok"
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user