fix: added sender retry and handled fail

This commit is contained in:
Riccardo
2023-12-16 08:56:20 +01:00
parent ac6b227870
commit bcc64eaef6
8 changed files with 199 additions and 138 deletions

View File

@@ -2,7 +2,7 @@ import { z } from 'zod';
import UnsubscribeTemplate from '../../../components/emails/unsubscribe';
import prisma from '../../../prisma/prisma';
import { ApiResponse } from '../../../utils/apiResponse';
import { sendEmail } from '../../../utils/sender';
import { sender } from '../../../utils/sender';
import { ResponseSchema, UnsubscribeFormSchema } from '../../../utils/types';
export const dynamic = 'force-dynamic'; // defaults to force-static
@@ -31,7 +31,11 @@ export async function POST(request: Request) {
}
});
await sendEmail([email], UnsubscribeTemplate());
const sent = await sender([email], UnsubscribeTemplate());
if (!sent) {
return ApiResponse(500, 'Internal server error');
}
}
const message: z.infer<typeof ResponseSchema> = {