Skip to content
Snippets Groups Projects
Commit 76dca9f5 authored by Marcelo Schmidt's avatar Marcelo Schmidt
Browse files

Enable robot calling methods on Rocket.Chat

parent 98dbc13c
No related branches found
No related tags found
No related merge requests found
......@@ -59,6 +59,7 @@ Package.onUse(function(api) {
api.addFiles('server/functions/setUsername.coffee', 'server');
api.addFiles('server/methods/joinDefaultChannels.coffee', 'server');
api.addFiles('server/methods/robotMethods.coffee', 'server');
api.addFiles('server/methods/sendInvitationEmail.coffee', 'server');
api.addFiles('server/methods/setAdminStatus.coffee', 'server');
api.addFiles('server/methods/setRealName.coffee', 'server');
......
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)
console.log call
return call
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment