🔥 Remove disabled queue implementation (#1452)

This commit is contained in:
Luke Vella 2024-12-01 21:41:15 +00:00 committed by GitHub
parent cf283c8ab3
commit ca207a913e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 30 deletions

View file

@ -1,16 +1,12 @@
import * as aws from "@aws-sdk/client-ses";
import { defaultProvider } from "@aws-sdk/credential-provider-node";
import { absoluteUrl } from "@rallly/utils/absolute-url";
import { renderAsync } from "@react-email/render";
import * as Sentry from "@sentry/nextjs";
import { waitUntil } from "@vercel/functions";
import type { Transporter } from "nodemailer";
import { createTransport } from "nodemailer";
import type Mail from "nodemailer/lib/mailer";
import React from "react";
import { i18nDefaultConfig, i18nInstance } from "./i18n";
import { createQstashClient } from "./queue";
import { templates } from "./templates";
import type { TemplateComponent, TemplateName, TemplateProps } from "./types";
@ -72,32 +68,8 @@ export class EmailClient {
templateName: T,
options: SendEmailOptions<T>,
) {
const isQueueEnabled = false; // TODO: Enable this
const createEmailJob = async () => {
const client = createQstashClient();
if (client && isQueueEnabled) {
const queue = client.queue({
queueName: "emails-mq",
});
queue
.enqueueJSON({
url: absoluteUrl("/api/send-email"),
body: { locale: this.config.locale, templateName, options },
retries: 2,
})
.catch(() => {
Sentry.captureException(new Error("Failed to queue email"));
// If there's an error queuing the email, send it immediately
this.sendTemplate(templateName, options);
});
} else {
this.sendTemplate(templateName, options);
}
};
waitUntil(createEmailJob());
const promise = this.sendTemplate(templateName, options);
waitUntil(promise);
}
async sendTemplate<T extends TemplateName>(