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

19 lines
671 B

Meteor.methods
'robot.modelCall': (model, method, args) ->
unless Meteor.userId()
throw new Meteor.Error 'invalid-user', '[methods] robot.modelCall -> Invalid user'
unless RocketChat.authz.hasRole Meteor.userId(), 'robot'
throw new Meteor.Error 'unauthorized', '[methods] robot.modelCall -> Unauthorized'
console.log '[method] robot.modelCall'.green, arguments
unless _.isFunction RocketChat.models[model]?[method]
throw new Meteor.Error 'invalid-method', '[methods] robot.modelCall -> Invalid method'
call = RocketChat.models[model][method].apply(RocketChat.models[model], args)
if call?.fetch?()?
return call.fetch()
else
return call