Skip to content

Commit

Permalink
Merge pull request #1967 from dubinc/skip-program-checks
Browse files Browse the repository at this point in the history
skipProgramChecks
  • Loading branch information
steven-tey authored Feb 3, 2025
2 parents 423580d + 20d317c commit 1635cb8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
7 changes: 0 additions & 7 deletions apps/web/app/api/links/[linkId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,6 @@ export const DELETE = withWorkspace(
linkId: params.linkId,
});

if (link.programId) {
throw new DubApiError({
code: "forbidden",
message: "You can't delete a link that's part of a program.",
});
}

const response = await deleteLink(link.id);

waitUntil(
Expand Down
1 change: 1 addition & 0 deletions apps/web/app/api/partners/links/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const POST = withWorkspace(
},
workspace,
userId: session.user.id,
skipProgramChecks: true, // skip this cause we've already validated the program above
});

if (error != null) {
Expand Down
4 changes: 3 additions & 1 deletion apps/web/lib/api/links/process-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ export async function processLink<T extends Record<string, any>>({
bulk = false,
skipKeyChecks = false, // only skip when key doesn't change (e.g. when editing a link)
skipExternalIdChecks = false, // only skip when externalId doesn't change (e.g. when editing a link)
skipProgramChecks = false,
}: {
payload: NewLinkProps & T;
workspace?: Pick<WorkspaceProps, "id" | "plan" | "flags">;
userId?: string;
bulk?: boolean;
skipKeyChecks?: boolean;
skipExternalIdChecks?: boolean;
skipProgramChecks?: boolean;
}): Promise<
| {
link: NewLinkProps & T;
Expand Down Expand Up @@ -370,7 +372,7 @@ export async function processLink<T extends Record<string, any>>({
}

// Program validity checks
if (programId) {
if (programId && !skipProgramChecks) {
const program = await prisma.program.findUnique({
where: { id: programId },
select: {
Expand Down

0 comments on commit 1635cb8

Please sign in to comment.