mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
37 lines
1004 B
JavaScript
37 lines
1004 B
JavaScript
import { authWithHeaders } from '../../middlewares/auth';
|
|
import * as inboxLib from '../../libs/inbox';
|
|
|
|
const 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
|
|
*
|
|
* @apiParam (Query) {Number} page Load the messages of the selected Page - 10 Messages per Page
|
|
* @apiParam (Query) {GUID} conversation Loads only the messages of a conversation
|
|
*
|
|
* @apiSuccess {Array} data An array of inbox messages
|
|
*/
|
|
api.getInboxMessages = {
|
|
method: 'GET',
|
|
url: '/inbox/messages',
|
|
middlewares: [authWithHeaders()],
|
|
async handler (req, res) {
|
|
const { user } = res.locals;
|
|
const { page } = req.query;
|
|
const { conversation } = req.query;
|
|
|
|
const userInbox = await inboxLib.getUserInbox(user, {
|
|
page, conversation,
|
|
});
|
|
|
|
res.respond(200, userInbox);
|
|
},
|
|
};
|
|
|
|
export default api;
|