subscribe to profiles

This commit is contained in:
Adolfo Reyna
2021-09-02 10:53:50 -07:00
parent ba2b0bcbd6
commit fa0d6ee199
5 changed files with 52 additions and 5 deletions

View File

@@ -11,6 +11,10 @@ DB.getDB.then((DB)=>{
return DB.ObjectID(user_sid);
}
const getProfileId = (req)=>{
return DB.ObjectID(req.cookies.profile_id || req.query.profile_id || req.body.profile_id);
}
router.get("/mine", async (req, res) => {
let userid = req.cookies.user_sid;
let profiles = await DB.getUserProfiles(userid);
@@ -65,6 +69,24 @@ 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);
return res.json({
status: "ok"
});
});
router.get("/groups/:id/unsubscribe", async (req, res) => {
const groupid = req.params.id;
const profileid = getProfileId(req);
DB.unsubscribeToGroup(profileid, groupid).then(console.log);
return res.json({
status: "ok"
});
});
router.get("/:id", async (req, res) => {
let profileId = req.params.id;
let profile = await DB.getProfile(profileId);