finalized contact email

This commit is contained in:
Omer Sabic 2024-06-25 21:34:52 +02:00
parent 94bd46a1f9
commit 3564d6c763

View File

@ -186,7 +186,26 @@ export const blogRoutes = (fastify, _, done) => {
}
}
}, async (req, reply) => {
const [blog] = await db.select().from(sites).where(eq(sites.id, req.body.blog_id));
if(!blog) {
return reply.code(400).send({
success: false,
code: "invalid_blog"
});
}
try {
await sendContactEmail(blog.contact_email, req.body.sender, req.body.subject, req.body.content);
} catch (e) {
return reply.code(500).send({
success: false,
code: "problem_sending"
});
}
return reply.send({
success: true
});
});
done();