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-livechat/server/methods/transfer.js

26 lines
847 B

/* eslint new-cap: [2, {"capIsNewExceptions": ["Match.Optional"]}] */
Meteor.methods({
'livechat:transfer'(transferData) {
if (!Meteor.userId() || !RocketChat.authz.hasPermission(Meteor.userId(), 'view-l-room')) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'livechat:transfer' });
}
check(transferData, {
roomId: String,
userId: Match.Optional(String),
deparmentId: Match.Optional(String)
});
const room = RocketChat.models.Rooms.findOneById(transferData.roomId);
const guest = RocketChat.models.Users.findOneById(room.v._id);
const user = Meteor.user();
if (room.usernames.indexOf(user.username) === -1) {
throw new Meteor.Error('error-not-authorized', 'Not authorized', { method: 'livechat:transfer' });
}
return RocketChat.Livechat.transfer(room, guest, transferData);
}
});