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/packages/rocketchat-authorization/client/lib/models/Subscriptions.js

40 lines
846 B

if (_.isUndefined(RocketChat.models.Subscriptions)) {
RocketChat.models.Subscriptions = {};
}
Object.assign(RocketChat.models.Subscriptions, {
isUserInRole(userId, roleName, roomId) {
if (roomId == null) {
return false;
}
const query = {
rid: roomId,
roles: roleName
};
return !_.isUndefined(this.findOne(query));
},
findUsersInRoles(roles, scope, options) {
roles = [].concat(roles);
const query = {
roles: { $in: roles }
};
if (scope) {
query.rid = scope;
}
const subscriptions = this.find(query).fetch();
const users = _.compact(_.map(subscriptions, function(subscription) {
if ('undefined' !== typeof subscription.u && 'undefined' !== typeof subscription.u._id) {
return subscription.u._id;
}
}));
return RocketChat.models.Users.find({ _id: { $in: users } }, options);
}
});