mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-29 02:06:34 +02:00
🔥 Remove disabled queue implementation (#1452)
This commit is contained in:
parent
cf283c8ab3
commit
ca207a913e
2 changed files with 2 additions and 30 deletions
|
@ -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>(
|
||||
|
|
Loading…
Add table
Reference in a new issue