Skip to content

Commit

Permalink
fix: handle spoke-portal being unreachable
Browse files Browse the repository at this point in the history
  • Loading branch information
bchrobot committed Dec 10, 2023
1 parent ede6e36 commit a10d807
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 a10d807

Please sign in to comment.