update profiles
This commit is contained in:
@@ -12,6 +12,17 @@ userDB = (DB) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DB.updateProfile = async (profileid, profileObj) => {
|
||||||
|
let tempProfile = profileObj.toObj();
|
||||||
|
const query = {_id: profileid};
|
||||||
|
const update = {$set: {profile: tempProfile.profile}};
|
||||||
|
let r = await DB.profileCols.updateOne(query, update).catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
DB.getProfile = async (profileId) => {
|
DB.getProfile = async (profileId) => {
|
||||||
//if (userProfileCache[profileId] && !userProfileCache[profileId].isGroup) return userProfileCache[profileId];
|
//if (userProfileCache[profileId] && !userProfileCache[profileId].isGroup) return userProfileCache[profileId];
|
||||||
const _id = DB.ObjectID(profileId);
|
const _id = DB.ObjectID(profileId);
|
||||||
|
|||||||
@@ -114,6 +114,18 @@ DB.getDB.then((DB)=>{
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post("/myProfile", async (req, res) => {
|
||||||
|
let profile = {
|
||||||
|
userid: getUserId(req),
|
||||||
|
profile: req.body
|
||||||
|
};
|
||||||
|
let profileObj = new Profile(profile); //validates profile
|
||||||
|
DB.updateProfile(getProfileId(req), profileObj);
|
||||||
|
return res.json({
|
||||||
|
status: "ok"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
router.get("/:id", async (req, res) => {
|
router.get("/:id", async (req, res) => {
|
||||||
let profileId = req.params.id;
|
let profileId = req.params.id;
|
||||||
let profile = await DB.getProfile(profileId);
|
let profile = await DB.getProfile(profileId);
|
||||||
|
|||||||
Reference in New Issue
Block a user