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/functions/removeUserFromRoom.js

23 lines
706 B

RocketChat.removeUserFromRoom = function(rid, user) {
const room = RocketChat.models.Rooms.findOneById(rid);
if (room) {
RocketChat.callbacks.run('beforeLeaveRoom', user, room);
RocketChat.models.Rooms.removeUsernameById(rid, user.username);
if (room.usernames.indexOf(user.username) !== -1) {
const removedUser = user;
RocketChat.models.Messages.createUserLeaveWithRoomIdAndUser(rid, removedUser);
}
if (room.t === 'l') {
RocketChat.models.Messages.createCommandWithRoomIdAndUser('survey', rid, user);
}
RocketChat.models.Subscriptions.removeByRoomIdAndUserId(rid, user._id);
Meteor.defer(function() {
RocketChat.callbacks.run('afterLeaveRoom', user, room);
});
}
};