Skip to content

Commit

Permalink
Add config for patreon fetch enablement
Browse files Browse the repository at this point in the history
  • Loading branch information
Brainicism committed Oct 23, 2023
1 parent 1235755 commit 90c3d7a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/helpers/patreon_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { updatePremium } from "./game_utils";
import Axios from "axios";
import dbContext from "../database_context";
import type Patron from "../interfaces/patron";
import KmqConfiguration from "../kmq_configuration";

Check warning on line 6 in src/helpers/patreon_manager.ts

View workflow job for this annotation

GitHub Actions / build

Expected type imports 'after' all other imports

const logger = new IPCLogger("patreon_manager");

Expand Down Expand Up @@ -84,6 +85,10 @@ function parsePatreonResponse(patreonResponse: PatreonResponse): Array<Patron> {
* Fetch up-to-date Patreon members and update Premium members accordingly
*/
export default async function updatePremiumUsers(): Promise<void> {
if (!KmqConfiguration.Instance.patreonFetchingEnabled()) {
return;
}

if (
!process.env.PATREON_CREATOR_ACCESS_TOKEN ||
!process.env.PATREON_CAMPAIGN_ID
Expand Down
4 changes: 4 additions & 0 deletions src/kmq_configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,8 @@ export default class KmqConfiguration {
persistMatchedSpotifySongs(): boolean {
return this.config["persistMatchedSpotifySongs"] ?? false;
}

patreonFetchingEnabled(): boolean {
return this.config["patreonFetchingEnabled"] ?? false;
}
}
2 changes: 1 addition & 1 deletion src/test/test_setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ before(async function () {
process.exit(1);
}

this.timeout(20000);
this.timeout(60000);
logger.info("Acquiring database connections");
const db = getNewConnection();
await sql`DROP DATABASE IF EXISTS kmq_test;`.execute(db.agnostic);
Expand Down

0 comments on commit 90c3d7a

Please sign in to comment.