Added Note Deletion
This commit is contained in:
parent
12da6f3c3e
commit
06dd2978b1
2 changed files with 30 additions and 2 deletions
|
@ -157,7 +157,7 @@ router.post('/like', (req, res) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/stream', (req, res) => {
|
router.post('/getPublic', (req, res) => {
|
||||||
if (!req.body.id) {
|
if (!req.body.id) {
|
||||||
utils.response_400(res, {
|
utils.response_400(res, {
|
||||||
id: 123,
|
id: 123,
|
||||||
|
@ -224,6 +224,34 @@ router.post('/stream', (req, res) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post('/delete', (req, res) => {
|
||||||
|
if (!req.body.uid || !req.body.nid) {
|
||||||
|
utils.response_400(res, {
|
||||||
|
uid: 123,
|
||||||
|
nid: 123
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var key = db.key(['Note', Number(req.body.nid)]);
|
||||||
|
db.get(key, (err, entity) => {
|
||||||
|
if (!entity || Number(utils.convertToNoteObj(entity)
|
||||||
|
.owner_id) != Number(req.body.uid)) {
|
||||||
|
utils.response_400(res, null, "The Note not exists OR he is not the owner of the note");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
db.delete(key, (err, apiResp) => {
|
||||||
|
if (!err) {
|
||||||
|
res.send({
|
||||||
|
status: "OK",
|
||||||
|
message: "Note Deleted"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
utils.response_500(res, "Error while Deleting Note");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
|
@ -5,7 +5,7 @@ module.exports = {
|
||||||
example_body: example,
|
example_body: example,
|
||||||
status: 'Error',
|
status: 'Error',
|
||||||
code: 400,
|
code: 400,
|
||||||
message: 'Bad request, ' + msg || 'see the example for more information'
|
message: 'Bad request, ' + (msg || 'see the example for more information')
|
||||||
};
|
};
|
||||||
res.send(r);
|
res.send(r);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue