mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +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) => {
|
Assert.message = helpers.try(async (req, res, next) => {
|
||||||
|
let roomId;
|
||||||
|
if (!req.params.roomId) {
|
||||||
|
roomId = await messaging.getMessageField(req.params.mid, 'roomId');
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!isFinite(req.params.mid) ||
|
!isFinite(req.params.mid) ||
|
||||||
!(await messaging.messageExists(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]]'));
|
return controllerHelpers.formatApiResponse(400, res, new Error('[[error:invalid-mid]]'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user