[NEW] Expose Livechat to Incoming Integrations and allow response

pull/6681/head
Rodrigo Nascimento 9 years ago
parent bcd507106e
commit d2ce5c995e
  1. 10
      packages/rocketchat-integrations/server/api/api.js

@ -10,6 +10,7 @@ function buildSandbox(store = {}) {
s,
console,
moment,
Livechat: RocketChat.Livechat,
Store: {
set(key, val) {
return store[key] = val;
@ -207,6 +208,10 @@ function executeIntegrationRest() {
return RocketChat.API.v1.failure(result.error);
}
this.bodyParams = result && result.content;
this.response = typeof result !== 'undefined' && result.response;
if (result.user) {
this.user = result.user;
}
logger.incoming.debug('[Process Incoming Request result of Trigger', this.integration.name, ':]');
logger.incoming.debug('result', this.bodyParams);
} catch ({stack}) {
@ -228,7 +233,10 @@ function executeIntegrationRest() {
if (_.isEmpty(message)) {
return RocketChat.API.v1.failure('unknown-error');
}
return RocketChat.API.v1.success();
if (this.response) {
logger.incoming.debug('response', this.response);
}
return RocketChat.API.v1.success(this.response);
} catch ({error}) {
return RocketChat.API.v1.failure(error);
}

Loading…
Cancel
Save