Skip to content

Commit c441bbf

Browse files
Added a flag to completely disable streams while i debug
1 parent 208736b commit c441bbf

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.example.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ USERS_CHECK_TIMEOUT = 1800
5050
USERS_BATCH_SIZE = 500
5151
## Set to 1 to disable this check at boot
5252
DISABLE_SANITY_CHECK = 0
53+
54+
# Disable streams completely.
55+
# This is only meant for debugging purposes and will make QTweet non-functional to most users.
56+
DISABLE_STREAMS = 0

src/twitter.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const tClient = new Twitter({
3232
access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET,
3333
});
3434

35+
const DISABLE_STREAMS = !!Number(process.env.DISABLE_STREAMS);
36+
3537
const reconnectionDelay = new Backup({
3638
mode: 'exponential',
3739
startValue: 2000,
@@ -447,7 +449,11 @@ export const createStream = async () => {
447449
log('No user IDs, no need to create a stream...');
448450
return null;
449451
}
450-
stream.create(userIds.map(({ twitterId }) => twitterId));
452+
if (!DISABLE_STREAMS) {
453+
stream.create(userIds.map(({ twitterId }) => twitterId));
454+
} else {
455+
log('ATTENTION: the DISABLE_STREAMS variable is set, meaning streams are currently not being created!');
456+
}
451457
return null;
452458
};
453459

0 commit comments

Comments
 (0)