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/server/models/Subscriptions.js

28 lines
683 B

RocketChat.models.Subscriptions.roleBaseQuery = function(userId, scope) {
var query = { "u._id": userId }
if (!_.isUndefined(scope)) {
query.rid = scope;
}
return query;
}
RocketChat.models.Subscriptions.findUsersInRoles = function(roles, scope, options) {
roles = [].concat(roles);
var query = {
roles: { $in: roles }
}
if (scope) {
query.rid = scope;
}
subscriptions = this.find(query).fetch();
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);
}