From 133dfa0f04fc8e27dabe21a830dd850ad9e058e2 Mon Sep 17 00:00:00 2001 From: Sergey Pimenov Date: Thu, 13 May 2021 13:16:37 +0300 Subject: [PATCH] fix balance sender if publicKey is not defined --- server/balance-sender.mjs | 7 ++----- server/node.mjs | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/server/balance-sender.mjs b/server/balance-sender.mjs index dd30db6..c48db02 100644 --- a/server/balance-sender.mjs +++ b/server/balance-sender.mjs @@ -4,16 +4,13 @@ import {TELEGRAM_BOT_URL} from "./telegram.mjs" import {parseTelegramChatIDs} from "./helpers.mjs"; export const processBalanceSend = async (config) => { - const {balanceSendInterval, telegramChatID, telegramToken} = config + const {balanceSendInterval, telegramChatID, telegramToken, publicKey} = config const TELEGRAM_URL = TELEGRAM_BOT_URL.replace("%TOKEN%", telegramToken) - if (!config.publicKey) return - if (!balanceSendInterval) return + if (!config || !telegramToken || !telegramChatID || !balanceSendInterval || !publicKey) return let status = await nodeInfo('balance', config) - if (!config || !telegramToken || !telegramChatID) return - if (status && status.data && status.data.account && status.data.account.balance) { const {total, liquid, locked, unknown, blockHeight} = status.data.account.balance const message = diff --git a/server/node.mjs b/server/node.mjs index 178b625..2cd8bc0 100644 --- a/server/node.mjs +++ b/server/node.mjs @@ -131,7 +131,7 @@ export const nodeInfo = async (obj, config) => { switch (obj) { case 'node-status': return await fetchGraphQL(graphql, queryNodeStatus) - case 'balance': return await fetchGraphQL(graphql, queryBalance.replace("%PUBLIC_KEY%", publicKey)) + case 'balance': return publicKey ? await fetchGraphQL(graphql, queryBalance.replace("%PUBLIC_KEY%", publicKey)) : 0 case 'blockchain': return await fetchGraphQL(graphql, queryBlockChain) case 'consensus': return await fetchGraphQL(graphql, queryConsensus) }