mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
New inbox client (#10644)
* new inbox client * add tests for sendPrivateMessage returning the message * update DELETE user message tests * port v3 GET-inbox_messages * use v4 delete message route * sendPrivateMessage: return sent message * fix
This commit is contained in:
committed by
Sabe Jones
parent
64507a161e
commit
84329e5fad
29
website/server/controllers/api-v3/inbox.js
Normal file
29
website/server/controllers/api-v3/inbox.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import { authWithHeaders } from '../../middlewares/auth';
|
||||
import { toArray, orderBy } from 'lodash';
|
||||
|
||||
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
|
||||
* @apiPrivate
|
||||
* @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) {
|
||||
const messagesObj = res.locals.user.inbox.messages;
|
||||
const messagesArray = orderBy(toArray(messagesObj), ['timestamp'], ['desc']);
|
||||
|
||||
res.respond(200, messagesArray);
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = api;
|
||||
Reference in New Issue
Block a user