|
|
@ -88,13 +88,13 @@ export const questionsAnswerCommentRouter = createProtectedRouter()
|
|
|
|
async resolve({ ctx, input }) {
|
|
|
|
async resolve({ ctx, input }) {
|
|
|
|
const userId = ctx.session?.user?.id;
|
|
|
|
const userId = ctx.session?.user?.id;
|
|
|
|
|
|
|
|
|
|
|
|
const questionCommentToUpdate = await ctx.prisma.questionsAnswerComment.findUnique({
|
|
|
|
const answerCommentToUpdate = await ctx.prisma.questionsAnswerComment.findUnique({
|
|
|
|
where: {
|
|
|
|
where: {
|
|
|
|
id: input.id,
|
|
|
|
id: input.id,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (questionCommentToUpdate?.id !== userId) {
|
|
|
|
if (answerCommentToUpdate?.id !== userId) {
|
|
|
|
throw new TRPCError({
|
|
|
|
throw new TRPCError({
|
|
|
|
code: 'UNAUTHORIZED',
|
|
|
|
code: 'UNAUTHORIZED',
|
|
|
|
message: 'User have no authorization to record.',
|
|
|
|
message: 'User have no authorization to record.',
|
|
|
@ -118,13 +118,13 @@ export const questionsAnswerCommentRouter = createProtectedRouter()
|
|
|
|
async resolve({ ctx, input }) {
|
|
|
|
async resolve({ ctx, input }) {
|
|
|
|
const userId = ctx.session?.user?.id;
|
|
|
|
const userId = ctx.session?.user?.id;
|
|
|
|
|
|
|
|
|
|
|
|
const questionCommentToUpdate = await ctx.prisma.questionsAnswerComment.findUnique({
|
|
|
|
const answerCommentToDelete = await ctx.prisma.questionsAnswerComment.findUnique({
|
|
|
|
where: {
|
|
|
|
where: {
|
|
|
|
id: input.id,
|
|
|
|
id: input.id,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (questionCommentToUpdate?.id !== userId) {
|
|
|
|
if (answerCommentToDelete?.id !== userId) {
|
|
|
|
throw new TRPCError({
|
|
|
|
throw new TRPCError({
|
|
|
|
code: 'UNAUTHORIZED',
|
|
|
|
code: 'UNAUTHORIZED',
|
|
|
|
message: 'User have no authorization to record.',
|
|
|
|
message: 'User have no authorization to record.',
|
|
|
|