Skip to content
Snippets Groups Projects
Unverified Commit 05374116 authored by gabriellsh's avatar gabriellsh Committed by GitHub
Browse files

[FIX] getUserMentionsByChannel method room permission (#25748)

parent 264f5509
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { Rooms, Users, Messages } from '../../../models';
import { canAccessRoom } from '../../../authorization/server';
Meteor.methods({
getUserMentionsByChannel({ roomId, options }) {
......@@ -13,16 +14,16 @@ Meteor.methods({
});
}
const user = Users.findOneById(Meteor.userId());
const room = Rooms.findOneById(roomId);
if (!room) {
if (!room || !canAccessRoom(room, user)) {
throw new Meteor.Error('error-invalid-room', 'Invalid room', {
method: 'getUserMentionsByChannel',
});
}
const user = Users.findOneById(Meteor.userId());
return Messages.findVisibleByMentionAndRoomId(user.username, roomId, options).fetch();
},
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment