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/removeUserFromRoom.coffee

25 lines
868 B

Meteor.methods
removeUserFromRoom: (data) ->
fromId = Meteor.userId()
# console.log '[methods] removeUserFromRoom -> '.green, 'fromId:', fromId, 'data:', data
room = RocketChat.models.Rooms.findOneById data.rid
if room.u?._id isnt Meteor.userId() and room.t is 'c'
throw new Meteor.Error 403, 'Not allowed'
removedUser = RocketChat.models.Users.findOneByUsername data.username
RocketChat.models.Rooms.removeUsernameById data.rid, data.username
RocketChat.models.Subscriptions.removeByRoomIdAndUserId data.rid, data.username
switch room.t
when 'c'
RocketChat.authz.removeUsersFromRole(removedUser._id; 'channel-moderator', data.rid)
when 'p'
RocketChat.authz.removeUsersFromRole(removedUser._id; 'group-moderator', data.rid)
RocketChat.models.Messages.createUserRemovedWithRoomIdAndUser data.rid, removedUser
return true