Skip to content

Commit

Permalink
fix patreon login
Browse files Browse the repository at this point in the history
  • Loading branch information
vintikzzz committed Feb 18, 2024
1 parent 56f09b5 commit 3ba202d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 26 deletions.
2 changes: 1 addition & 1 deletion api/dist/patreon.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function makeUser(d, patreonCampaignId, patreonRoles) {
const tierIds = jp.query(d, `$.included[?(@.type=="member" && @.relationships.campaign.data.id == "${patreonCampaignId}")].relationships.currently_entitled_tiers..id`);

for (const [role, id] of Object.entries(patreonRoles)) {
if (tierIds.includes(id)) user.role = role;
if (tierIds.includes(id.toString())) user.role = role;
}

const lastChargeStatus = jp.value(d, `$.included[?(@.type=="member" && @.relationships.campaign.data.id == "${patreonCampaignId}")].attributes.last_charge_status`);
Expand Down
19 changes: 7 additions & 12 deletions api/dist/test/patreon.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@ const assert = require('assert');
const rewire = require('rewire');

const patreon = rewire('../patreon.js');

const {
roles
} = require('../roles');

const tiers = ["3981231", "3972747", "3981014", "3981042", "3981061"];
const patreonCampaignId = 3166075;
const patreonTiers = [roles.BRONZE_BACKER, roles.SILVER_BACKER, roles.GOLD_BACKER, roles.EMERALD_SPONSOR, roles.RUBY_SPONSOR];
const patreonRoles = {};

for (let i = 0; i < tiers.length; i++) {
patreonRoles[patreonTiers[i]] = tiers[i];
}
const patreonRoles = {
BRONZE_BACKER: 3981231,
SILVER_BACKER: 3972747,
GOLD_BACKER: 3981014,
EMERALD_SPONSOR: 3981042,
RUBY_SPONSOR: 3981061
};

const makeUser = patreon.__get__('makeUser');

Expand Down
2 changes: 1 addition & 1 deletion api/src/patreon.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function makeUser(d, patreonCampaignId, patreonRoles) {

const tierIds = jp.query(d, `$.included[?(@.type=="member" && @.relationships.campaign.data.id == "${patreonCampaignId}")].relationships.currently_entitled_tiers..id`);
for (const [role, id] of Object.entries(patreonRoles)) {
if (tierIds.includes(id)) user.role = role;
if (tierIds.includes(id.toString())) user.role = role;
}

const lastChargeStatus = jp.value(d, `$.included[?(@.type=="member" && @.relationships.campaign.data.id == "${patreonCampaignId}")].attributes.last_charge_status`);
Expand Down
18 changes: 6 additions & 12 deletions api/src/test/patreon.spec.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
const assert = require('assert');
const rewire = require('rewire');
const patreon = rewire('../patreon.js');
const { roles } = require('../roles');
const tiers = [
"3981231",
"3972747",
"3981014",
"3981042",
"3981061"
];
const patreonCampaignId = 3166075;
const patreonTiers = [roles.BRONZE_BACKER, roles.SILVER_BACKER, roles.GOLD_BACKER, roles.EMERALD_SPONSOR, roles.RUBY_SPONSOR];
const patreonRoles = {};
for (let i = 0; i < tiers.length; i++) {
patreonRoles[patreonTiers[i]] = tiers[i];
const patreonRoles = {
BRONZE_BACKER: 3981231,
SILVER_BACKER: 3972747,
GOLD_BACKER: 3981014,
EMERALD_SPONSOR: 3981042,
RUBY_SPONSOR: 3981061
}
const makeUser = patreon.__get__('makeUser');

Expand Down

0 comments on commit 3ba202d

Please sign in to comment.