diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-07-07 16:56:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-07 16:56:52 +0200 |
commit | ebd2dde688b61b3987dc8e209921d964d10a33de (patch) | |
tree | c1aad2c62d3a7de392d05b32afc3e9665c14d058 /streaming | |
parent | 6e1261f277411300e4f1d24f8c1b14ad1a165915 (diff) |
Restore streaming API output format (#4100)
* Restore streaming API output format Regression from #4090 * Remove whitespace
Diffstat (limited to 'streaming')
-rw-r--r-- | streaming/index.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/streaming/index.js b/streaming/index.js index 400456d24..6ee8baea8 100644 --- a/streaming/index.js +++ b/streaming/index.js @@ -262,11 +262,12 @@ const startWorker = (workerId) => { const { event, payload, queued_at } = JSON.parse(message); const transmit = () => { - const now = new Date().getTime(); - const delta = now - queued_at; + const now = new Date().getTime(); + const delta = now - queued_at; + const encodedPayload = typeof payload === 'number' ? payload : JSON.stringify(payload); - log.silly(req.requestId, `Transmitting for ${req.accountId}: ${event} ${payload} Delay: ${delta}ms`); - output(event, payload); + log.silly(req.requestId, `Transmitting for ${req.accountId}: ${event} ${encodedPayload} Delay: ${delta}ms`); + output(event, encodedPayload); }; if (notificationOnly && event !== 'notification') { @@ -282,7 +283,7 @@ const startWorker = (workerId) => { return; } - const unpackedPayload = JSON.parse(payload); + const unpackedPayload = payload; const targetAccountIds = [unpackedPayload.account.id].concat(unpackedPayload.mentions.map(item => item.id)); const accountDomain = unpackedPayload.account.acct.split('@')[1]; |