Skip to content

Commit

Permalink
emails fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
potts99 committed Nov 29, 2023
1 parent 25b7488 commit 8ed54db
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 34 deletions.
2 changes: 1 addition & 1 deletion apps/api/src/controllers/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/lib/imap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
};

Expand Down
40 changes: 23 additions & 17 deletions apps/client/pages/admin/email-queues/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div>
Expand Down
31 changes: 17 additions & 14 deletions apps/client/pages/admin/email-queues/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,23 @@ export default function EmailQueues() {
const [tls, setTls] = useState();

async function newQueue() {
await fetch("/api/v1/admin/email-queue/new", {
method: "post",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + getCookie("session"),
},
body: JSON.stringify({
name,
username,
password,
hostname,
tls,
}),
})
await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/api/v1/email-queue/create`,
{
method: "post",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + getCookie("session"),
},
body: JSON.stringify({
name,
username,
password,
hostname,
tls,
}),
}
)
.then((res) => res.json())
.then(() => {
router.back("/admin/email-queues");
Expand Down

0 comments on commit 8ed54db

Please sign in to comment.