📢 Add Featurebase (#796)

This commit is contained in:
Luke Vella 2023-08-01 21:27:20 +01:00 committed by GitHub
parent 5532723d23
commit 222947292b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 151 additions and 157 deletions

View file

@ -1,37 +0,0 @@
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}`,
});
}),
});

View file

@ -1,6 +1,5 @@
import { mergeRouters, router } from "../trpc";
import { auth } from "./auth";
import { feedback } from "./feedback";
import { polls } from "./polls";
import { user } from "./user";
import { userPreferences } from "./user-preferences";
@ -12,7 +11,6 @@ export const appRouter = mergeRouters(
auth,
polls,
user,
feedback,
userPreferences,
}),
);