From cdba3eb786cc59dad144911a1a940dda3ac2e3b2 Mon Sep 17 00:00:00 2001 From: Chris Pitman Date: Thu, 5 Oct 2017 12:58:31 -0400 Subject: [PATCH] Store int history as string in mongo Http Results can include keps which are vaild JSON but invalid mongo keys. Store them as a string, then check when formatting them for dispkay if they are json that needs to be stringifies or already a string. --- .../client/views/integrationsOutgoingHistory.html | 2 +- .../client/views/integrationsOutgoingHistory.js | 12 ++++-------- .../server/lib/triggerHandler.js | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/rocketchat-integrations/client/views/integrationsOutgoingHistory.html b/packages/rocketchat-integrations/client/views/integrationsOutgoingHistory.html index eb57c122e3ad..e58d746a2d08 100644 --- a/packages/rocketchat-integrations/client/views/integrationsOutgoingHistory.html +++ b/packages/rocketchat-integrations/client/views/integrationsOutgoingHistory.html @@ -121,7 +121,7 @@

-
{{{ hljsStack history.errorStack }}}
+
{{{ jsonStringify history.errorStack }}}
{{/if}} diff --git a/packages/rocketchat-integrations/client/views/integrationsOutgoingHistory.js b/packages/rocketchat-integrations/client/views/integrationsOutgoingHistory.js index 383b5d1ba9bd..9a110dffd58f 100644 --- a/packages/rocketchat-integrations/client/views/integrationsOutgoingHistory.js +++ b/packages/rocketchat-integrations/client/views/integrationsOutgoingHistory.js @@ -94,16 +94,12 @@ Template.integrationsOutgoingHistory.helpers({ }, jsonStringify(data) { - return data ? hljs.highlight('json', JSON.stringify(data, null, 2)).value : ''; - }, - - hljsStack(errorStack) { - if (!errorStack) { + if (!data) { return ''; - } else if (typeof errorStack === 'object') { - return hljs.highlight('json', JSON.stringify(errorStack, null, 2)).value; + } else if (typeof data === 'object') { + return hljs.highlight('json', JSON.stringify(data, null, 2)).value; } else { - return hljs.highlight('json', errorStack).value; + return hljs.highlight('json', data).value; } }, diff --git a/packages/rocketchat-integrations/server/lib/triggerHandler.js b/packages/rocketchat-integrations/server/lib/triggerHandler.js index 5012c42e6436..000a1d5af854 100644 --- a/packages/rocketchat-integrations/server/lib/triggerHandler.js +++ b/packages/rocketchat-integrations/server/lib/triggerHandler.js @@ -130,7 +130,7 @@ RocketChat.integrations.triggerHandler = new class RocketChatIntegrationHandler } if (typeof httpResult !== 'undefined') { - history.httpResult = httpResult; + history.httpResult = JSON.stringify(httpResult, null, 2); } if (typeof error !== 'undefined') {