performance: private messages - API (#11077)

* paging for inbox

* clean up
This commit is contained in:
negue
2019-03-31 20:52:53 +02:00
committed by Matteo Pagliazzi
parent f35ef3a046
commit 0b82722d27
6 changed files with 45 additions and 12 deletions

View File

@@ -11,6 +11,8 @@ let api = {};
* @apiGroup Inbox
* @apiDescription Get inbox messages for a user
*
* @apiParam (Query) {Number} page Load the messages of the selected Page - 10 Messages per Page
*
* @apiSuccess {Array} data An array of inbox messages
*/
api.getInboxMessages = {
@@ -19,8 +21,11 @@ api.getInboxMessages = {
middlewares: [authWithHeaders()],
async handler (req, res) {
const user = res.locals.user;
const page = req.query.page;
const userInbox = await inboxLib.getUserInbox(user);
const userInbox = await inboxLib.getUserInbox(user, {
page,
});
res.respond(200, userInbox);
},