subscribe to profiles
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user