mirror of
https://github.com/lukevella/rallly.git
synced 2025-08-03 00:19:03 +02:00
♻️ Create backend package (#643)
This commit is contained in:
parent
7fc08c6736
commit
05fe2edaea
68 changed files with 476 additions and 391 deletions
37
packages/backend/trpc/routers/feedback.ts
Normal file
37
packages/backend/trpc/routers/feedback.ts
Normal file
|
@ -0,0 +1,37 @@
|
|||
import { prisma } from "@rallly/database";
|
||||
import { sendRawEmail } from "@rallly/emails";
|
||||
import { z } from "zod";
|
||||
|
||||
import { publicProcedure, router } from "../trpc";
|
||||
|
||||
export const feedback = router({
|
||||
send: publicProcedure
|
||||
.input(z.object({ content: z.string() }))
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
let replyTo: string | undefined;
|
||||
let name = "Guest";
|
||||
|
||||
if (!ctx.user.isGuest) {
|
||||
const user = await prisma.user.findUnique({
|
||||
where: { id: ctx.user.id },
|
||||
select: { email: true, name: true },
|
||||
});
|
||||
|
||||
if (user) {
|
||||
replyTo = user.email;
|
||||
name = user.name;
|
||||
}
|
||||
}
|
||||
|
||||
await sendRawEmail({
|
||||
to: process.env.NEXT_PUBLIC_FEEDBACK_EMAIL,
|
||||
from: {
|
||||
name: "Rallly Feedback Form",
|
||||
address: process.env.SUPPORT_EMAIL ?? "",
|
||||
},
|
||||
subject: "Feedback",
|
||||
replyTo,
|
||||
text: `${name} says:\n\n${input.content}`,
|
||||
});
|
||||
}),
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue