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/app/e2e/server/methods/getUsersOfRoomWithoutKey.js

27 lines
828 B

import { Meteor } from 'meteor/meteor';
import { Subscriptions, Users } from '../../../models';
Meteor.methods({
'e2e.getUsersOfRoomWithoutKey'(rid) {
const userId = Meteor.userId();
if (!userId) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'e2e.getUsersOfRoomWithoutKey' });
}
const room = Meteor.call('canAccessRoom', rid, userId);
if (!room) {
throw new Meteor.Error('error-invalid-room', 'Invalid room', { method: 'e2e.getUsersOfRoomWithoutKey' });
}
const subscriptions = Subscriptions.findByRidWithoutE2EKey(rid, { fields: { 'u._id': 1 } }).fetch();
const userIds = subscriptions.map((s) => s.u._id);
const options = { fields: { 'e2e.public_key': 1 } };
const users = Users.findByIdsWithPublicE2EKey(userIds, options).fetch();
return {
users,
};
},
});