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/methods/robotMethods.coffee

21 lines
681 B

Meteor.methods
'robot.modelCall': (model, method, args) ->
check model, String
check method, String
unless Meteor.userId()
throw new Meteor.Error 'error-invalid-user', 'Invalid user', { method: 'robot.modelCall' }
unless RocketChat.authz.hasRole Meteor.userId(), 'robot'
throw new Meteor.Error 'error-not-allowed', 'Not allowed', { method: 'robot.modelCall' }
unless _.isFunction RocketChat.models[model]?[method]
throw new Meteor.Error 'error-invalid-method', 'Invalid method', { method: 'robot.modelCall' }
call = RocketChat.models[model][method].apply(RocketChat.models[model], args)
if call?.fetch?()?
return call.fetch()
else
return call