Skip to content

Commit

Permalink
fix: retry creating campaign message errors
Browse files Browse the repository at this point in the history
  • Loading branch information
marian2js committed Jun 19, 2024
1 parent bf51b3b commit e229d03
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions apps/api/src/chat/services/broadcast.consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,22 @@ export class BroadcastConsumer {
job.progress(campaign.processed / campaign.total)
} catch (e) {
if (e.message.includes('is not on the XMTP network') || e.message.includes('self messaging not supported')) {
await this.campaignMessageService.createOne({
campaign: campaign._id,
address: contact.address,
})
campaign.processed++
job.progress(campaign.processed / campaign.total)
try {
await this.campaignMessageService.createOne({
campaign: campaign._id,
address: contact.address,
})
campaign.processed++
job.progress(campaign.processed / campaign.total)
} catch (e) {
await wait(5000)
await this.campaignMessageService.createOne({
campaign: campaign._id,
address: contact.address,
})
campaign.processed++
job.progress(campaign.processed / campaign.total)
}
} else {
this.logger.error(`Failed to send broadcast message from ${user.address} to ${sendTo}: ${e.message}`)
failed++
Expand Down

0 comments on commit e229d03

Please sign in to comment.