Skip to content

Commit

Permalink
Merge branch 'master' into fix/callback
Browse files Browse the repository at this point in the history
  • Loading branch information
zxt-tzx committed Jul 6, 2023
2 parents 2e11f63 + 59cfda3 commit f19331a
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions worker/src/core/loaders/message-worker/util/govsg.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,27 @@ class Govsg {
}
)
}
return validatedWhatsAppIds
.filter((message) => message.status === 'valid')
.map((message) => ({
...message,
body: '', // just putting this in to satisfy the interface grrr
}))

const validMessages = validatedWhatsAppIds.filter(
(message) => message.status === 'valid'
)

if (validMessages.length === 0) {
// Has to run one more time get_messages db function to set the job
// queue item to `SENT` if needed
await this.postmanConnection.query(
'SELECT get_messages_to_send_govsg(:jobId, :rate);',
{
replacements: { jobId, rate },
type: QueryTypes.SELECT,
}
)
}

return validMessages.map((message) => ({
...message,
body: '', // just putting this in to satisfy the interface grrr
}))
} catch (error) {
logger.error({
message: '[govsg.class.getMessages] Error processing messages',
Expand Down

0 comments on commit f19331a

Please sign in to comment.