mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user