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

20 lines
654 B

import { Meteor } from 'meteor/meteor';
import { Livechat } from '../lib/Livechat';
Meteor.methods({
'livechat:changeLivechatStatus'() {
if (!Meteor.userId()) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'livechat:changeLivechatStatus' });
}
const user = Meteor.user();
const newStatus = user.statusLivechat === 'available' ? 'not-available' : 'available';
if (!Livechat.allowAgentChangeServiceStatus(newStatus)) {
throw new Meteor.Error('error-office-hours-are-closed', 'Not allowed', { method: 'livechat:changeLivechatStatus' });
}
return Livechat.setUserStatusLivechat(user._id, newStatus);
},
});