parent
68b06419df
commit
93b16413d3
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 60 KiB |
@ -0,0 +1,30 @@ |
||||
/* 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}); |
||||
} |
||||
}); |
||||
Loading…
Reference in new issue