From 618e6c9d27d2a271f0c44885d52c578be34cda93 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sun, 22 Nov 2026 11:23:48 +0100 Subject: [PATCH] Bugfix/twitter bot service without credentials (#8434) * Skip twitter bot service without credentials * Update changelog --- CHANGELOG.md | 1 + .../configuration/configuration.service.ts | 8 ++-- .../twitter-bot/twitter-bot.service.ts | 40 ++++++++++++++----- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e98abd35e4..e8d85de3e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed the duplicate data point of today in the chart of the holding detail dialog +- Fixed the requests of the twitter bot service with dummy credentials ## 3.100.0 - 2026-11-15 diff --git a/apps/api/src/services/configuration/configuration.service.ts b/apps/api/src/services/configuration/configuration.service.ts index ea2312d5bf..76ff80deb8 100644 --- a/apps/api/src/services/configuration/configuration.service.ts +++ b/apps/api/src/services/configuration/configuration.service.ts @@ -148,10 +148,10 @@ export class ConfigurationService { }), STRIPE_SECRET_KEY: str({ default: '' }), TRUST_PROXY: trustProxy({ default: '' }), - TWITTER_ACCESS_TOKEN: str({ default: 'dummyAccessToken' }), - TWITTER_ACCESS_TOKEN_SECRET: str({ default: 'dummyAccessTokenSecret' }), - TWITTER_API_KEY: str({ default: 'dummyApiKey' }), - TWITTER_API_SECRET: str({ default: 'dummyApiSecret' }) + TWITTER_ACCESS_TOKEN: str({ default: '' }), + TWITTER_ACCESS_TOKEN_SECRET: str({ default: '' }), + TWITTER_API_KEY: str({ default: '' }), + TWITTER_API_SECRET: str({ default: '' }) }); } diff --git a/apps/api/src/services/twitter-bot/twitter-bot.service.ts b/apps/api/src/services/twitter-bot/twitter-bot.service.ts index b49a49e1dd..1a3d3a62ff 100644 --- a/apps/api/src/services/twitter-bot/twitter-bot.service.ts +++ b/apps/api/src/services/twitter-bot/twitter-bot.service.ts @@ -17,7 +17,7 @@ import { TwitterApi, TwitterApiReadWrite } from 'twitter-api-v2'; export class TwitterBotService implements OnModuleInit { private readonly logger = new Logger(TwitterBotService.name); - private twitterClient: TwitterApiReadWrite; + private twitterClient?: TwitterApiReadWrite; public constructor( private readonly benchmarkService: BenchmarkService, @@ -27,18 +27,40 @@ export class TwitterBotService implements OnModuleInit { ) {} public onModuleInit() { - this.twitterClient = new TwitterApi({ - accessSecret: this.configurationService.get( - 'TWITTER_ACCESS_TOKEN_SECRET' - ), - accessToken: this.configurationService.get('TWITTER_ACCESS_TOKEN'), - appKey: this.configurationService.get('TWITTER_API_KEY'), - appSecret: this.configurationService.get('TWITTER_API_SECRET') - }).readWrite; + const accessSecret = this.configurationService.get( + 'TWITTER_ACCESS_TOKEN_SECRET' + ); + const accessToken = this.configurationService.get('TWITTER_ACCESS_TOKEN'); + const appKey = this.configurationService.get('TWITTER_API_KEY'); + const appSecret = this.configurationService.get('TWITTER_API_SECRET'); + + const areCredentialsSet = !!( + accessSecret && + accessToken && + appKey && + appSecret + ); + + if (areCredentialsSet) { + this.twitterClient = new TwitterApi({ + accessSecret, + accessToken, + appKey, + appSecret + }).readWrite; + } else if ( + this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX') && + this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') + ) { + this.logger.warn( + 'ENABLE_FEATURE_FEAR_AND_GREED_INDEX and ENABLE_FEATURE_SUBSCRIPTION are enabled, but not all TWITTER_* credentials are set. The twitter bot service does not post the Fear & Greed Index.' + ); + } } public async tweetFearAndGreedIndex() { if ( + !this.twitterClient || !this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX') || isWeekend(new Date()) ) {