The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/server/methods/readThreads.js

31 lines
918 B

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { settings } from '../../app/settings/server';
import { Messages, Rooms } from '../../app/models/server';
import { canAccessRoom } from '../../app/authorization/server';
import { readThread } from '../../app/threads/server/functions';
Meteor.methods({
readThreads(tmid) {
check(tmid, String);
if (!Meteor.userId() || !settings.get('Threads_enabled')) {
throw new Meteor.Error('error-not-allowed', 'Threads Disabled', { method: 'getThreadMessages' });
}
const thread = Messages.findOneById(tmid);
if (!thread) {
return;
}
const user = Meteor.user();
const room = Rooms.findOneById(thread.rid);
if (!canAccessRoom(room, user)) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'getThreadMessages' });
}
return readThread({ userId: user._id, rid: thread.rid, tmid });
},
});