diff --git a/api/dist/patreon.js b/api/dist/patreon.js index 0e61490..776b3b6 100644 --- a/api/dist/patreon.js +++ b/api/dist/patreon.js @@ -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`); diff --git a/api/dist/test/patreon.spec.js b/api/dist/test/patreon.spec.js index 761c119..a602435 100644 --- a/api/dist/test/patreon.spec.js +++ b/api/dist/test/patreon.spec.js @@ -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'); diff --git a/api/src/patreon.js b/api/src/patreon.js index 5fef410..ef0da50 100644 --- a/api/src/patreon.js +++ b/api/src/patreon.js @@ -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`); diff --git a/api/src/test/patreon.spec.js b/api/src/test/patreon.spec.js index 44709cb..97d3867 100644 --- a/api/src/test/patreon.spec.js +++ b/api/src/test/patreon.spec.js @@ -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');