mirror of
https://github.com/lukevella/rallly.git
synced 2025-04-30 02:36:30 +02:00
🔥 Remove disabled queue implementation
This commit is contained in:
parent
659307ca0b
commit
90f69151d8
2 changed files with 2 additions and 30 deletions
|
@ -1,16 +1,12 @@
|
||||||
import * as aws from "@aws-sdk/client-ses";
|
import * as aws from "@aws-sdk/client-ses";
|
||||||
import { defaultProvider } from "@aws-sdk/credential-provider-node";
|
import { defaultProvider } from "@aws-sdk/credential-provider-node";
|
||||||
import { absoluteUrl } from "@rallly/utils/absolute-url";
|
|
||||||
import { renderAsync } from "@react-email/render";
|
import { renderAsync } from "@react-email/render";
|
||||||
import * as Sentry from "@sentry/nextjs";
|
|
||||||
import { waitUntil } from "@vercel/functions";
|
import { waitUntil } from "@vercel/functions";
|
||||||
import type { Transporter } from "nodemailer";
|
import type { Transporter } from "nodemailer";
|
||||||
import { createTransport } from "nodemailer";
|
import { createTransport } from "nodemailer";
|
||||||
import type Mail from "nodemailer/lib/mailer";
|
import type Mail from "nodemailer/lib/mailer";
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
import { i18nDefaultConfig, i18nInstance } from "./i18n";
|
import { i18nDefaultConfig, i18nInstance } from "./i18n";
|
||||||
import { createQstashClient } from "./queue";
|
|
||||||
import { templates } from "./templates";
|
import { templates } from "./templates";
|
||||||
import type { TemplateComponent, TemplateName, TemplateProps } from "./types";
|
import type { TemplateComponent, TemplateName, TemplateProps } from "./types";
|
||||||
|
|
||||||
|
@ -72,32 +68,8 @@ export class EmailClient {
|
||||||
templateName: T,
|
templateName: T,
|
||||||
options: SendEmailOptions<T>,
|
options: SendEmailOptions<T>,
|
||||||
) {
|
) {
|
||||||
const isQueueEnabled = false; // TODO: Enable this
|
const promise = this.sendTemplate(templateName, options);
|
||||||
const createEmailJob = async () => {
|
waitUntil(promise);
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendTemplate<T extends TemplateName>(
|
async sendTemplate<T extends TemplateName>(
|
||||||
|
|
Loading…
Add table
Reference in a new issue