Inbox: Add API to list conversations (#11110)

* Add API to list inbox conversations

* fix test + add api doc

* use `.lean()`

* orderBy after the the grouped conversations are loaded

* fix ordering
This commit is contained in:
negue
2019-04-26 18:45:05 +02:00
committed by Matteo Pagliazzi
parent 3be075ad43
commit 83070e211d
5 changed files with 122 additions and 5 deletions

View File

@@ -72,4 +72,25 @@ api.clearMessages = {
},
};
/**
* @api {get} /inbox/conversations Get the conversations for a user
* @apiName conversations
* @apiGroup Inbox
* @apiDescription Get the conversations for a user
*
* @apiSuccess {Array} data An array of inbox conversations
*/
api.conversations = {
method: 'GET',
middlewares: [authWithHeaders()],
url: '/inbox/conversations',
async handler (req, res) {
const user = res.locals.user;
const result = await inboxLib.listConversations(user);
res.respond(200, result);
},
};
module.exports = api;