add private groups
This commit is contained in:
@@ -68,6 +68,18 @@ DB.getDB.then((DB)=>{
|
||||
});
|
||||
});
|
||||
|
||||
router.post("/groups/accept", 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 profileAcepted = DB.ObjectID(req.body.profileid);
|
||||
DB.acceptGroupJoinReq(profileAcepted, groupid);
|
||||
//Add Notification to accepted user
|
||||
return res.json({
|
||||
status: "ok"
|
||||
});
|
||||
});
|
||||
|
||||
router.get("/groups/:id", async (req, res) => {
|
||||
const groupid = req.params.id;
|
||||
let groups = await DB.getGroup(groupid);
|
||||
@@ -80,7 +92,9 @@ DB.getDB.then((DB)=>{
|
||||
router.get("/groups/:id/subscribe", async (req, res) => {
|
||||
const groupid = req.params.id;
|
||||
const profileid = getProfileId(req);
|
||||
DB.subscribeToGroup(profileid, groupid);
|
||||
const isPrivate = await DB.isGroupPrivate(groupid);
|
||||
DB.subscribeToGroup(profileid, groupid, isPrivate);
|
||||
//Add notification to group owner
|
||||
return res.json({
|
||||
status: "ok"
|
||||
});
|
||||
@@ -90,6 +104,7 @@ DB.getDB.then((DB)=>{
|
||||
const groupid = req.params.id;
|
||||
const profileid = getProfileId(req);
|
||||
DB.unsubscribeToGroup(profileid, groupid);
|
||||
//Add notification to group owner
|
||||
return res.json({
|
||||
status: "ok"
|
||||
});
|
||||
@@ -139,6 +154,7 @@ DB.getDB.then((DB)=>{
|
||||
let followProfileId = req.params.id;
|
||||
const profileid = getProfileId(req);
|
||||
DB.followProfile(profileid, followProfileId);
|
||||
//Add notification to user
|
||||
return res.json({
|
||||
status: "ok"
|
||||
});
|
||||
@@ -148,6 +164,7 @@ DB.getDB.then((DB)=>{
|
||||
let followProfileId = req.params.id;
|
||||
const profileid = getProfileId(req);
|
||||
DB.unfollowProfile(profileid, followProfileId);
|
||||
//Add notification to user
|
||||
return res.json({
|
||||
status: "ok"
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user