save-and-restore-progress-for-audio fix #12 #14
@ -136,21 +136,6 @@ router
|
||||
});
|
||||
});
|
||||
|
||||
router
|
||||
.route("/progress")
|
||||
.post(passport.authenticate("jwt", { session: false }), (req, res) => {
|
||||
let item = req.body;
|
||||
item.userId = req.user._id;
|
||||
database.progress.update(item);
|
||||
res.status(200).end();
|
||||
})
|
||||
.delete(passport.authenticate("jwt", { session: false }), (req, res) => {
|
||||
let item = req.body;
|
||||
item.userId = req.user._id;
|
||||
database.progress.delete(item);
|
||||
res.status(200).end();
|
||||
});
|
||||
|
||||
router
|
||||
.route("/history")
|
||||
.post(passport.authenticate("jwt", { session: false }), (req, res) => {
|
||||
@ -169,12 +154,30 @@ router
|
||||
});
|
||||
});
|
||||
|
||||
router.route("/progress/:parent")
|
||||
router
|
||||
.route("/progress")
|
||||
.post(passport.authenticate("jwt", { session: false }), (req, res) => {
|
||||
let item = req.body;
|
||||
item.userId = req.user._id;
|
||||
database.progress.update(item);
|
||||
res.status(200).end();
|
||||
});
|
||||
|
||||
router
|
||||
.route("/progress/:parent")
|
||||
.get(passport.authenticate("jwt", { session: false }), (req, res) => {
|
||||
database.progress.get(req.params.parent, result => {
|
||||
res.json(result).end();
|
||||
});
|
||||
})
|
||||
.delete(passport.authenticate("jwt", { session: false }), (req, res) => {
|
||||
let item = {
|
||||
parentId: req.params.parent,
|
||||
userId: req.user._id
|
||||
}
|
||||
database.progress.delete(item);
|
||||
res.status(200).end();
|
||||
});
|
||||
|
||||
router
|
||||
.route("/settings")
|
||||
|
@ -21,7 +21,7 @@ exports.update = function (item) {
|
||||
};
|
||||
|
||||
exports.delete = function (item) {
|
||||
dbo.collection("progress").deleteMany({ userId: ObjectId(item.userId), id: item.id }, (err) => {
|
||||
dbo.collection("progress").deleteMany({ userId: ObjectId(item.userId), parentId: item.parentId }, (err) => {
|
||||
if (err) throw err;
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user