Added Note Deletion

This commit is contained in:
Sagi Dayan 2016-07-03 13:38:29 +03:00
parent 12da6f3c3e
commit 06dd2978b1
2 changed files with 30 additions and 2 deletions

View file

@ -157,7 +157,7 @@ router.post('/like', (req, res) => {
}
});
router.post('/stream', (req, res) => {
router.post('/getPublic', (req, res) => {
if (!req.body.id) {
utils.response_400(res, {
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;

View file

@ -5,7 +5,7 @@ module.exports = {
example_body: example,
status: 'Error',
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);
},