Fix profile update persistence and stale cache
This commit is contained in:
@@ -760,16 +760,28 @@ DB.getDB.then((DB) => {
|
||||
* type: string
|
||||
*/
|
||||
router.post("/myProfile", async (req, res) => {
|
||||
let profile = {
|
||||
userid: getUserId(req),
|
||||
profile: req.body.profile,
|
||||
data: req.body.data
|
||||
};
|
||||
let profileObj = new Profile(profile); //validates profile
|
||||
DB.updateProfile(getProfileId(req), profileObj);
|
||||
return res.json({
|
||||
status: "ok"
|
||||
});
|
||||
try {
|
||||
let profile = {
|
||||
userid: getUserId(req),
|
||||
profile: req.body.profile,
|
||||
data: req.body.data
|
||||
};
|
||||
let profileObj = new Profile(profile); //validates profile
|
||||
const updateRes = await DB.updateProfile(getProfileId(req), profileObj);
|
||||
if (!updateRes || !updateRes.matchedCount) {
|
||||
return res.status(400).json({
|
||||
status: "Could not update profile"
|
||||
});
|
||||
}
|
||||
return res.json({
|
||||
status: "ok"
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error updating myProfile", error);
|
||||
return res.status(500).json({
|
||||
status: "Internal server error"
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user