From 41c5bee44c71f6f80d633dda830534aadab64c98 Mon Sep 17 00:00:00 2001 From: Mohamad Mohebifar Date: Sat, 28 Dec 2024 10:06:38 -0800 Subject: [PATCH] feat: Allow verified publishers override codemods (#1432) --- apps/backend/src/publishHandler.ts | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/apps/backend/src/publishHandler.ts b/apps/backend/src/publishHandler.ts index 76bad9fde..c273348a2 100644 --- a/apps/backend/src/publishHandler.ts +++ b/apps/backend/src/publishHandler.ts @@ -283,21 +283,23 @@ export const publishHandler: RouteHandler<{ arguments: codemodRc.arguments, }; - // Check if a codemod with the name already exists from other author - const existingCodemod = await prisma.codemod.findUnique({ - where: { - name, - author: { - not: author, + if (!isVerified) { + // Check if a codemod with the name already exists from other author + const existingCodemod = await prisma.codemod.findUnique({ + where: { + name, + author: { + not: author, + }, }, - }, - }); - - if (existingCodemod !== null) { - return reply.code(400).send({ - error: CODEMOD_NAME_TAKEN, - errorText: `Codemod name \`${name}\` is already taken.`, }); + + if (existingCodemod !== null) { + return reply.code(400).send({ + error: CODEMOD_NAME_TAKEN, + errorText: `Codemod name \`${name}\` is already taken.`, + }); + } } let createdAtTimestamp: number;