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/ignoreUser.js

30 lines
928 B

/* globals RocketChat */
Meteor.methods({
ignoreUser({rid, userId: ignoredUser, ignore = true}) {
check(ignoredUser, String);
check(rid, String);
check(ignore, Boolean);
const userId = Meteor.userId();
if (!userId) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'ignoreUser'
});
}
const subscription = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(rid, userId);
if (!subscription) {
throw new Meteor.Error('error-invalid-subscription', 'Invalid subscription', { method: 'ignoreUser' });
}
const subscriptionIgnoredUser = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(rid, ignoredUser);
if (!subscriptionIgnoredUser) {
throw new Meteor.Error('error-invalid-subscription', 'Invalid subscription', { method: 'ignoreUser' });
}
return !!RocketChat.models.Subscriptions.ignoreUser({_id: subscription._id, ignoredUser, ignore});
}
});