2018-08-30 19:50:03 +00:00
|
|
|
import { authWithHeaders } from '../../middlewares/auth';
|
2018-09-21 13:12:20 +00:00
|
|
|
import * as inboxLib from '../../libs/inbox';
|
2018-08-30 19:50:03 +00:00
|
|
|
|
|
|
|
|
let api = {};
|
|
|
|
|
|
|
|
|
|
/* NOTE most inbox routes are either in the user or members controller */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @api {get} /api/v3/inbox/messages Get inbox messages for a user
|
|
|
|
|
* @apiName GetInboxMessages
|
|
|
|
|
* @apiGroup Inbox
|
|
|
|
|
* @apiDescription Get inbox messages for a user
|
|
|
|
|
*
|
|
|
|
|
* @apiSuccess {Array} data An array of inbox messages
|
|
|
|
|
*/
|
|
|
|
|
api.getInboxMessages = {
|
|
|
|
|
method: 'GET',
|
|
|
|
|
url: '/inbox/messages',
|
|
|
|
|
middlewares: [authWithHeaders()],
|
|
|
|
|
async handler (req, res) {
|
2018-09-21 13:12:20 +00:00
|
|
|
const user = res.locals.user;
|
2018-08-30 19:50:03 +00:00
|
|
|
|
2018-09-21 13:12:20 +00:00
|
|
|
const userInbox = await inboxLib.getUserInbox(user);
|
|
|
|
|
|
|
|
|
|
res.respond(200, userInbox);
|
2018-08-30 19:50:03 +00:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = api;
|