diff --git a/apps/api/src/controllers/queue.ts b/apps/api/src/controllers/queue.ts index ae7dcdaa7..cd5e26114 100644 --- a/apps/api/src/controllers/queue.ts +++ b/apps/api/src/controllers/queue.ts @@ -60,7 +60,7 @@ export function emailQueueRoutes(fastify: FastifyInstance) { const token = checkToken(bearer); if (token) { - const { id }: any = request.params; + const { id }: any = request.body; await prisma.emailQueue.delete({ where: { diff --git a/apps/api/src/lib/imap.ts b/apps/api/src/lib/imap.ts index e20f625e7..5b3697c00 100644 --- a/apps/api/src/lib/imap.ts +++ b/apps/api/src/lib/imap.ts @@ -22,8 +22,8 @@ export const getEmails = async () => { user: queues[i].username, password: queues[i].password, host: queues[i].hostname, - port: 993, - tls: true, + port: queues[i].tls ? 993 : 110, + tls: queues[i].tls, tlsOptions: { servername: queues[i].hostname }, }; diff --git a/apps/client/pages/admin/email-queues/index.js b/apps/client/pages/admin/email-queues/index.js index b9f2be136..147f343cd 100644 --- a/apps/client/pages/admin/email-queues/index.js +++ b/apps/client/pages/admin/email-queues/index.js @@ -6,33 +6,39 @@ export default function EmailQueues() { const [queues, setQueues] = useState(); async function fetchQueues() { - const res = await fetch("/api/v1/admin/email-queue/check", { - headers: { - "Content-Type": "application/json", - Authorization: "Bearer " + getCookie("session"), - }, - }).then((res) => res.json()); + const res = await fetch( + `${process.env.NEXT_PUBLIC_API_URL}/api/v1/email-queues/all`, + { + headers: { + "Content-Type": "application/json", + Authorization: "Bearer " + getCookie("session"), + }, + } + ).then((res) => res.json()); setQueues(res.queues); } async function deleteItem(id) { - await fetch("/api/v1/admin/email-queue/delete", { - method: "post", - headers: { - "Content-Type": "application/json", - Authorization: "Bearer " + getCookie("session"), - }, - body: JSON.stringify({ - id, - }), - }) + await fetch( + `${process.env.NEXT_PUBLIC_API_URL}/api/v1/email-queue/delete`, + { + method: "post", + headers: { + "Content-Type": "application/json", + Authorization: "Bearer " + getCookie("session"), + }, + body: JSON.stringify({ + id, + }), + } + ) .then((res) => res.json()) .then(() => fetchQueues()); } useEffect(() => { fetchQueues(); - }); + }, []); return (