Skip to content

Commit

Permalink
chore: Improve sendgrid error messaging (#666)
Browse files Browse the repository at this point in the history
* chore: Improve sendgrid error messaging

* cleanup console logs
  • Loading branch information
sashko9807 authored Sep 3, 2024
1 parent 3403202 commit 66a6354
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions apps/api/src/campaign/campaign.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1036,30 +1036,35 @@ export class CampaignService {

async createCampaignNotificationList(updated: { title: string; id: string }) {
// Generate list in the marketing platform
let listId: string
const lists = await this.marketingNotificationsService.provider.getContactLists()
const campaignEmailLists = lists.body.result
const exists = campaignEmailLists.find((campaign) => campaign.name === updated.title)
if (exists) {
listId = exists.id
} else {
listId = await this.marketingNotificationsService.provider.createNewContactList({
name: updated.title || updated.id,
})
}
try {
let listId: string
const lists = await this.marketingNotificationsService.provider.getContactLists()
const campaignEmailLists = lists.body.result
const exists = campaignEmailLists.find((campaign) => campaign.name === updated.title)
if (exists) {
listId = exists.id
} else {
listId = await this.marketingNotificationsService.provider.createNewContactList({
name: updated.title || updated.id,
})
}

const name = updated.title || ''
const name = updated.title || ''

// Save the list_id in the DB
await this.prisma.notificationList.create({
data: {
id: listId,
name: name.slice(0, 99),
campaignId: updated.id,
},
})
// Save the list_id in the DB
await this.prisma.notificationList.create({
data: {
id: listId,
name: name.slice(0, 99),
campaignId: updated.id,
},
})

return listId
return listId
} catch (err) {
console.log(err)
throw new InternalServerErrorException(JSON.stringify(err.response.body.errors))
}
}

async sendNewCampaignNotification(
Expand Down

0 comments on commit 66a6354

Please sign in to comment.