Add route to cadastre new integrations via API

pull/1744/head
Rodrigo Nascimento 10 years ago
parent 4745f771cc
commit 1790480840
  1. 26
      packages/rocketchat-integrations/server/api/api.coffee

@ -100,3 +100,29 @@ Api.addRoute ':integrationId/:userId/:token', authRequired: true,
statusCode: 200
body:
success: true
Api.addRoute 'manageintegrations/:integrationId/:userId/:token', authRequired: true,
post: ->
if @bodyParams?.payload?
@bodyParams = JSON.parse @bodyParams.payload
integration = RocketChat.models.Integrations.findOne(@urlParams.integrationId)
user = RocketChat.models.Users.findOne(@userId)
if not integration?
return {} =
statusCode: 400
body:
success: false
error: 'Invalid integraiton id'
switch @bodyParams.action
when 'addOutgoingIntegration'
Meteor.runAsUser user._id, =>
Meteor.call 'addOutgoingIntegration', @bodyParams.data
return {} =
statusCode: 200
body:
success: true

Loading…
Cancel
Save