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-lib/server/methods/blockUser.js

23 lines
661 B

Meteor.methods({
blockUser({rid, blocked}) {
check(rid, String);
check(blocked, String);
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'blockUser' });
}
const subscription = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(rid, Meteor.userId());
const subscription2 = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(rid, blocked);
if (!subscription || !subscription2) {
throw new Meteor.Error('error-invalid-room', 'Invalid room', { method: 'blockUser' });
}
RocketChat.models.Subscriptions.setBlockedByRoomId(rid, blocked, Meteor.userId());
return true;
}
});