Added User Avatar to note response
This commit is contained in:
parent
06dd2978b1
commit
b2808ef65e
2 changed files with 45 additions and 33 deletions
|
@ -57,6 +57,17 @@ router.post('/upsert', (req, res) => {
|
|||
}
|
||||
});
|
||||
} else { //** Create a new Note **//
|
||||
var key = db.key(['User', Number(req.body.owner_id)]);
|
||||
db.get(key, (err, entity) => {
|
||||
if (err) {
|
||||
utils.response_500(res, "DB Error");
|
||||
return;
|
||||
}
|
||||
if (!entity) {
|
||||
utils.response_400(res, null, "No User with that id!");
|
||||
return;
|
||||
}
|
||||
var user = utils.convertToUserObj(entity);
|
||||
db.save({
|
||||
key: db.key('Note'),
|
||||
data: {
|
||||
|
@ -70,6 +81,7 @@ router.post('/upsert', (req, res) => {
|
|||
created_at: Date.now(),
|
||||
likes: 0,
|
||||
tags: req.body.tags || [],
|
||||
avatar: user.avatar
|
||||
}
|
||||
},
|
||||
(err, response) => {
|
||||
|
@ -87,7 +99,7 @@ router.post('/upsert', (req, res) => {
|
|||
else utils.response_500(res, "DB Error->" + err);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@ module.exports = {
|
|||
is_public: note.data.is_public,
|
||||
created_at: note.data.created_at,
|
||||
likes: note.data.likes,
|
||||
tags: note.data.tags
|
||||
tags: note.data.tags,
|
||||
avatar: note.data.avatar
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue