mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-25 08:15:12 +00:00
upd: fix donationUrl check position
This commit is contained in:
parent
6b459be117
commit
9dd51bc9eb
1 changed files with 15 additions and 14 deletions
|
@ -49,31 +49,32 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
};
|
};
|
||||||
|
|
||||||
if (ps.instance) {
|
if (ps.instance) {
|
||||||
return { sponsor_data: await maybeCached('instanceSponsors', ps.forceUpdate, async () => {
|
const meta = await this.metaService.fetch();
|
||||||
let totalSponsors;
|
if (meta.donationUrl && !meta.donationUrl.includes('opencollective.com')) {
|
||||||
const meta = await this.metaService.fetch();
|
return [];
|
||||||
|
} else if (meta.donationUrl) {
|
||||||
if (meta.donationUrl && !meta.donationUrl.includes('opencollective.com')) {
|
return { sponsor_data: await maybeCached('instanceSponsors', ps.forceUpdate, async () => {
|
||||||
return [];
|
let totalSponsors;
|
||||||
} else if (meta.donationUrl) {
|
const meta = await this.metaService.fetch();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const backers = await fetch(`${meta.donationUrl}/members/users.json`).then((response) => response.json());
|
const backers = await fetch(`${meta.donationUrl}/members/users.json`).then((response) => response.json());
|
||||||
|
|
||||||
// Merge both together into one array and make sure it only has Active subscriptions
|
// Merge both together into one array and make sure it only has Active subscriptions
|
||||||
const allSponsors = [...backers].filter(sponsor => sponsor.isActive === true && sponsor.role === 'BACKER' && sponsor.tier);
|
const allSponsors = [...backers].filter(sponsor => sponsor.isActive === true && sponsor.role === 'BACKER' && sponsor.tier);
|
||||||
|
|
||||||
// Remove possible duplicates
|
// Remove possible duplicates
|
||||||
totalSponsors = [...new Map(allSponsors.map(v => [v.profile, v])).values()];
|
totalSponsors = [...new Map(allSponsors.map(v => [v.profile, v])).values()];
|
||||||
|
|
||||||
await this.redisClient.set('instanceSponsors', JSON.stringify(totalSponsors), 'EX', 3600);
|
await this.redisClient.set('instanceSponsors', JSON.stringify(totalSponsors), 'EX', 3600);
|
||||||
return totalSponsors;
|
return totalSponsors;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
} else {
|
}) };
|
||||||
return [];
|
} else {
|
||||||
}
|
return [];
|
||||||
}) };
|
}
|
||||||
} else {
|
} else {
|
||||||
return { sponsor_data: await maybeCached('sponsors', ps.forceUpdate, async () => {
|
return { sponsor_data: await maybeCached('sponsors', ps.forceUpdate, async () => {
|
||||||
let totalSponsors;
|
let totalSponsors;
|
||||||
|
|
Loading…
Reference in a new issue