Squashed commit of the following:

commit 43cfebd97a8981805e0fdb661188e3f8b753c54e
Author: BennyKok <itechbenny@gmail.com>
Date:   Fri Jan 26 07:33:30 2024 +0000

    fix: only create share slug when public-share deployment
This commit is contained in:
bennykok 2024-01-26 15:40:42 +08:00
parent 4bca9a7376
commit 15e1b1ccb4

View File

@ -62,10 +62,10 @@ export async function createDeployments(
const userName = workflow.org_id const userName = workflow.org_id
? await clerkClient.organizations ? await clerkClient.organizations
.getOrganization({ .getOrganization({
organizationId: workflow.org_id, organizationId: workflow.org_id,
}) })
.then((x) => x.name) .then((x) => x.name)
: workflow.user.name; : workflow.user.name;
await db.insert(deploymentsTable).values({ await db.insert(deploymentsTable).values({
@ -75,7 +75,8 @@ export async function createDeployments(
machine_id, machine_id,
environment, environment,
org_id: orgId, org_id: orgId,
share_slug: slugify(`${userName} ${workflow.name}`), // only create share slug if this is plublic share
share_slug: environment == "public-share" ? slugify(`${userName} ${workflow.name}`) : null
}); });
} }
revalidatePath(`/${workflow_id}`); revalidatePath(`/${workflow_id}`);
@ -247,9 +248,9 @@ export async function findUserShareDeployment(share_id: string) {
orgId orgId
? eq(deploymentsTable.org_id, orgId) ? eq(deploymentsTable.org_id, orgId)
: and( : and(
eq(deploymentsTable.user_id, userId), eq(deploymentsTable.user_id, userId),
isNull(deploymentsTable.org_id), isNull(deploymentsTable.org_id),
), ),
), ),
); );