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/saveTrigger.js

28 lines
750 B

import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';
import { hasPermission } from '../../../authorization';
import { LivechatTrigger } from '../../../models';
Meteor.methods({
'livechat:saveTrigger'(trigger) {
if (!Meteor.userId() || !hasPermission(Meteor.userId(), 'view-livechat-manager')) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'livechat:saveTrigger' });
}
check(trigger, {
_id: Match.Maybe(String),
name: String,
description: String,
enabled: Boolean,
runOnce: Boolean,
conditions: Array,
actions: Array,
});
if (trigger._id) {
return LivechatTrigger.updateById(trigger._id, trigger);
}
return LivechatTrigger.insert(trigger);
},
});