Skip to content

Commit

Permalink
Merge pull request #283 from Klimatbyran/fix/281-discord-review-butto…
Browse files Browse the repository at this point in the history
…ns-for-empty-diff

Fix #281 - Only show Discord review button for actual changes that need to be reviewed
  • Loading branch information
hugo-nl authored Nov 25, 2024
2 parents 2319eaf + 07c7284 commit 27bcfca
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/workers/saveToAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,22 @@ const saveToAPI = new DiscordWorker<JobData>(
: ''

if (diff) {
if (diff === 'NO CHANGES') {
await job.sendMessage({
content: `# ${companyName}: \`${apiSubEndpoint}\`
${diff}`.slice(0, 2000),
})

return diff
}

const buttonRow = discord.createButtonRow(job.id!)
await job.sendMessage({
content: `# ${companyName}: \`${apiSubEndpoint}\`
${diff}`.slice(0, 2000),
components: [buttonRow],
})

if (diff === 'NO CHANGES') {
return diff
}

return await job.moveToDelayed(Date.now() + ONE_DAY)
} else {
if (scope12?.length || scope3?.length || biogenic?.length) {
Expand Down

0 comments on commit 27bcfca

Please sign in to comment.