finalized contact email
This commit is contained in:
parent
94bd46a1f9
commit
3564d6c763
@ -186,7 +186,26 @@ export const blogRoutes = (fastify, _, done) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, async (req, reply) => {
|
}, 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();
|
done();
|
||||||
|
Loading…
Reference in New Issue
Block a user