Skip to content

Commit

Permalink
fix: handle spoke-portal being unreachable (politics-rewired#1675)
Browse files Browse the repository at this point in the history
  • Loading branch information
bchrobot authored and ajohn25 committed Aug 6, 2024
1 parent 6bfcd8b commit 214e260
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions src/server/lib/notices/register-10dlc-brand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,30 @@ export const get10DlcBrandNotices: OrgLevelNotificationGetter = async (

const ownedProfiles = profiles.filter(({ roles }) => roles.includes("OWNER"));

const profilesWithChannels = await Promise.all(
profiles.map(async ({ messaging_service_sid }) => {
const payload = {
operationName: "GetSwitchboardProfile",
query: fetchProfileQuery,
variables: {
profileId: messaging_service_sid
}
};

const profileResponse = await request.post(PORTAL_API_URL).send(payload);
return profileResponse.body.data?.profile;
})
);
let profilesWithChannels: any[] = [];
try {
profilesWithChannels = await Promise.all(
profiles.map(async ({ messaging_service_sid }) => {
const payload = {
operationName: "GetSwitchboardProfile",
query: fetchProfileQuery,
variables: {
profileId: messaging_service_sid
}
};

const profileResponse = await request
.post(PORTAL_API_URL)
.timeout(1000)
.send(payload);

return profileResponse.body.data?.profile;
})
);
} catch {
// Error fetching from Portal (it may not be reachable)
return [];
}

// if a registered profile exists, show the notice for their lowest cost pricing plan

Expand Down

0 comments on commit 214e260

Please sign in to comment.