From 4cc03fe11dccf336ff1ff58b9a4be50773b9769f Mon Sep 17 00:00:00 2001 From: Jakob Frank Date: Thu, 15 Feb 2018 19:25:39 +0100 Subject: [PATCH] found another place where the legacy/rocket.chat service is called (closes #236) --- packages/assistify-ai/server/SmartiProxy.js | 2 +- packages/assistify-ai/server/lib/SmartiAdapter.js | 3 +-- .../assistify-ai/server/methods/SmartiWidgetBackend.js | 7 ++++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/assistify-ai/server/SmartiProxy.js b/packages/assistify-ai/server/SmartiProxy.js index e6e2fc2ed8706..5c7cea60e3fa2 100644 --- a/packages/assistify-ai/server/SmartiProxy.js +++ b/packages/assistify-ai/server/SmartiProxy.js @@ -55,7 +55,7 @@ export class SmartiProxy { } } - SystemLogger.error('Could not complete', method, 'to', url); + SystemLogger.error('Could not complete', method, 'to', url, error.response); SystemLogger.debug(error); } } diff --git a/packages/assistify-ai/server/lib/SmartiAdapter.js b/packages/assistify-ai/server/lib/SmartiAdapter.js index da43a6add7b7b..75751df81afe7 100644 --- a/packages/assistify-ai/server/lib/SmartiAdapter.js +++ b/packages/assistify-ai/server/lib/SmartiAdapter.js @@ -73,8 +73,7 @@ export class SmartiAdapter { } else { SystemLogger.debug('Smarti - Trying legacy service to retrieve conversation ID...'); const conversation = SmartiProxy.propagateToSmarti(verbs.get, - `legacy/rocket.chat?channel_id=${ message.rid }`, null, - function (error) { + `legacy/rocket.chat?channel_id=${ message.rid }`, null, (error) => { // 404 is expected if no mapping exists if (error.response.statusCode === 404) { return null; diff --git a/packages/assistify-ai/server/methods/SmartiWidgetBackend.js b/packages/assistify-ai/server/methods/SmartiWidgetBackend.js index 34a786a070451..aa1a2fd3fc2bc 100644 --- a/packages/assistify-ai/server/methods/SmartiWidgetBackend.js +++ b/packages/assistify-ai/server/methods/SmartiWidgetBackend.js @@ -32,7 +32,12 @@ Meteor.methods({ return !RocketChat.authz.hasPermission(userId, 'send-many-messages'); } } - )(verbs.get, `legacy/rocket.chat?channel_id=${ channelId }`); + )(verbs.get, `legacy/rocket.chat?channel_id=${ channelId }`, null, (error) => { + // 404 is expected if no mapping exists + if (error.response.statusCode === 404) { + return null; + } + }); if (conversation && conversation.id) { let timestamp = conversation.messages &&