diff --git a/lib/routes/twitter/utils.js b/lib/routes/twitter/utils.js index 74c54e75ef..d4bdf17173 100644 --- a/lib/routes/twitter/utils.js +++ b/lib/routes/twitter/utils.js @@ -110,28 +110,31 @@ const ProcessFeed = ({ data = [] }, showAuthor = false) => { }); }; -const consumer_keys = config.twitter.consumer_key.split(','); -const consumer_secrets = config.twitter.consumer_secret.split(','); -const T = {}; -let count = 0; -let index = -1; +let getTwit = () => null; +if (config.twitter.consumer_key && config.twitter.consumer_secret) { + const consumer_keys = config.twitter.consumer_key.split(','); + const consumer_secrets = config.twitter.consumer_secret.split(','); + const T = {}; + let count = 0; + let index = -1; -consumer_keys.forEach((consumer_key, index) => { - const consumer_secret = consumer_secrets[index]; - if (consumer_key && consumer_secret) { - T[index] = new Twit({ - consumer_key, - consumer_secret, - app_only_auth: true, - }); - count = index + 1; - } -}); + consumer_keys.forEach((consumer_key, index) => { + const consumer_secret = consumer_secrets[index]; + if (consumer_key && consumer_secret) { + T[index] = new Twit({ + consumer_key, + consumer_secret, + app_only_auth: true, + }); + count = index + 1; + } + }); -const getTwit = () => { - index++; - return T[index % count]; -}; + getTwit = () => { + index++; + return T[index % count]; + }; +} module.exports = { ProcessFeed,