mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 10:35:55 +01:00
feat: update mdidleware.assert.message so roomId is optional
This commit is contained in:
@@ -146,10 +146,15 @@ Assert.room = helpers.try(async (req, res, next) => {
|
||||
});
|
||||
|
||||
Assert.message = helpers.try(async (req, res, next) => {
|
||||
let roomId;
|
||||
if (!req.params.roomId) {
|
||||
roomId = await messaging.getMessageField(req.params.mid, 'roomId');
|
||||
}
|
||||
|
||||
if (
|
||||
!isFinite(req.params.mid) ||
|
||||
!(await messaging.messageExists(req.params.mid)) ||
|
||||
!(await messaging.canViewMessage(req.params.mid, req.params.roomId, req.uid))
|
||||
!(await messaging.canViewMessage(req.params.mid, roomId || req.params.roomId, req.uid))
|
||||
) {
|
||||
return controllerHelpers.formatApiResponse(400, res, new Error('[[error:invalid-mid]]'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user