Disable unavailable subreddits after Reddit 404

This commit is contained in:
jjbrunton committed 2026-08-08 22:53:24 +01:00
1 parent 664aa5c098
commit dcf57273e2
13 files changed
+153 -12

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
import type { Config } from '../config/index.js';
import type { ConfigPersistence } from '../config/index.js';
import type { Logger } from '../utils/logger.js';
import type { SubredditPollingControl } from './monitor.js';
/** Persists a terminal Reddit listing failure so every account stops polling it. */
export function createConfigBackedSubredditPollingControl(
config: Config,
configStore: ConfigPersistence,
logger: Logger,
): SubredditPollingControl {
return {
disableUnavailableSubreddit(subreddit: string): void {
const entry = config.reddit.subreddits.find((candidate) => candidate.name.toLowerCase() === subreddit.toLowerCase());
if (!entry || entry.enabled === false) return;
entry.enabled = false;
configStore.save(config);
logger.warn(`Persisted disabled status for unavailable subreddit r/${entry.name}`);
},
isSubredditEnabled(subreddit: string): boolean {
return config.reddit.subreddits.find((entry) => entry.name.toLowerCase() === subreddit.toLowerCase())?.enabled !== false;
},
};
}