Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move email errors to error channel on slack #134

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/resend/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ export async function sendConfirmationEmail(show) {
// send message to slack saying there was an issue sending the email
console.log(error);
sendSlackMessage(
`Failed to send email request to ${artist.name}(${artist.email}) on show *${show.title}*. ${error.name} - ${error.message}. <@U04HG3VHHEW>`
`Failed to send email request to ${artist.name}(${artist.email}) on show *${show.title}*. ${error.name} - ${error.message}. <@U04HG3VHHEW>`,
"error"
);
}
}
Expand Down Expand Up @@ -109,7 +110,8 @@ export async function sendArtworkEmail(artist, date) {
// send message to slack saying there was an issue sending the email
console.log(error);
sendSlackMessage(
`Failed to send artwork email to ${artist.name}(${artist.email}). ${error.name} - ${error.message}. <@U04HG3VHHEW>`
`Failed to send artwork email to ${artist.name}(${artist.email}). ${error.name} - ${error.message}. <@U04HG3VHHEW>`,
"error"
);
}
}
Expand Down
12 changes: 8 additions & 4 deletions lib/slack.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
const slackURL = process.env.SLACK_WEBHOOK_URL;
const slackDevURL = process.env.SLACK_DEV_WEBHOOK_URL;
const slackErrorURL = process.env.SLACK_ERROR_WEBHOOK_URL;

export function sendSlackMessage(text: string, channel?: string) {
let url = slackURL;
if (channel && channel == "dev") {
url = slackDevURL;
}
const urlMap = {
error: slackErrorURL,
dev: slackDevURL,
};

const url = urlMap[channel] || slackURL;

fetch(url, {
method: "POST",
body: JSON.stringify({
Expand Down
3 changes: 2 additions & 1 deletion pages/api/admin/artwork-email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export default async function handler(
error
);
await sendSlackMessage(
`Failed to send email request to ${artist.name} (${artist.email}) for show *${show.title}*. Error: ${error.message}. <@U04HG3VHHEW>`
`Failed to send email request to ${artist.name} (${artist.email}) for show *${show.title}*. Error: ${error.message}. <@U04HG3VHHEW>`,
"error"
);
}
}
Expand Down
Loading