mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-24 04:38:46 +00:00
Merge pull request #5103 from shuv-o/fix/project-permission-column-limit
fix: prevent Postgres 100-arg limit crash and restore data parity for restricted-member project access
(cherry picked from commit 6d8aa9d8da)
[skip ci]
This commit is contained in:
committed by
Dokploy Bot
parent
e541308a4f
commit
a691b469a1
@@ -38,6 +38,7 @@ import {
|
|||||||
checkProjectAccess,
|
checkProjectAccess,
|
||||||
findMemberByUserId,
|
findMemberByUserId,
|
||||||
} from "@dokploy/server/services/permission";
|
} from "@dokploy/server/services/permission";
|
||||||
|
import { serviceColumns } from "@dokploy/server/services/project";
|
||||||
import { TRPCError } from "@trpc/server";
|
import { TRPCError } from "@trpc/server";
|
||||||
import { and, desc, eq, ilike, or, sql } from "drizzle-orm";
|
import { and, desc, eq, ilike, or, sql } from "drizzle-orm";
|
||||||
import type { AnyPgColumn } from "drizzle-orm/pg-core";
|
import type { AnyPgColumn } from "drizzle-orm/pg-core";
|
||||||
@@ -130,39 +131,63 @@ export const projectRouter = createTRPCRouter({
|
|||||||
environments: {
|
environments: {
|
||||||
with: {
|
with: {
|
||||||
applications: {
|
applications: {
|
||||||
|
columns: {
|
||||||
|
...serviceColumns,
|
||||||
|
applicationId: true,
|
||||||
|
icon: true,
|
||||||
|
},
|
||||||
|
with: { server: { columns: { name: true } } },
|
||||||
where: buildServiceFilter(
|
where: buildServiceFilter(
|
||||||
applications.applicationId,
|
applications.applicationId,
|
||||||
accessedServices,
|
accessedServices,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
compose: {
|
compose: {
|
||||||
|
columns: {
|
||||||
|
...serviceColumns,
|
||||||
|
composeId: true,
|
||||||
|
composeStatus: true,
|
||||||
|
},
|
||||||
|
with: { server: { columns: { name: true } } },
|
||||||
where: buildServiceFilter(
|
where: buildServiceFilter(
|
||||||
compose.composeId,
|
compose.composeId,
|
||||||
accessedServices,
|
accessedServices,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
libsql: {
|
libsql: {
|
||||||
|
columns: { ...serviceColumns, libsqlId: true },
|
||||||
|
with: { server: { columns: { name: true } } },
|
||||||
where: buildServiceFilter(libsql.libsqlId, accessedServices),
|
where: buildServiceFilter(libsql.libsqlId, accessedServices),
|
||||||
},
|
},
|
||||||
mariadb: {
|
mariadb: {
|
||||||
|
columns: { ...serviceColumns, mariadbId: true },
|
||||||
|
with: { server: { columns: { name: true } } },
|
||||||
where: buildServiceFilter(
|
where: buildServiceFilter(
|
||||||
mariadb.mariadbId,
|
mariadb.mariadbId,
|
||||||
accessedServices,
|
accessedServices,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
mongo: {
|
mongo: {
|
||||||
|
columns: { ...serviceColumns, mongoId: true },
|
||||||
|
with: { server: { columns: { name: true } } },
|
||||||
where: buildServiceFilter(mongo.mongoId, accessedServices),
|
where: buildServiceFilter(mongo.mongoId, accessedServices),
|
||||||
},
|
},
|
||||||
mysql: {
|
mysql: {
|
||||||
|
columns: { ...serviceColumns, mysqlId: true },
|
||||||
|
with: { server: { columns: { name: true } } },
|
||||||
where: buildServiceFilter(mysql.mysqlId, accessedServices),
|
where: buildServiceFilter(mysql.mysqlId, accessedServices),
|
||||||
},
|
},
|
||||||
postgres: {
|
postgres: {
|
||||||
|
columns: { ...serviceColumns, postgresId: true },
|
||||||
|
with: { server: { columns: { name: true } } },
|
||||||
where: buildServiceFilter(
|
where: buildServiceFilter(
|
||||||
postgres.postgresId,
|
postgres.postgresId,
|
||||||
accessedServices,
|
accessedServices,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
redis: {
|
redis: {
|
||||||
|
columns: { ...serviceColumns, redisId: true },
|
||||||
|
with: { server: { columns: { name: true } } },
|
||||||
where: buildServiceFilter(redis.redisId, accessedServices),
|
where: buildServiceFilter(redis.redisId, accessedServices),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -47,16 +47,16 @@ export const createProject = async (
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const findProjectById = async (projectId: string) => {
|
export const serviceColumns = {
|
||||||
const serviceColumns = {
|
name: true,
|
||||||
name: true,
|
description: true,
|
||||||
description: true,
|
appName: true,
|
||||||
appName: true,
|
createdAt: true,
|
||||||
createdAt: true,
|
serverId: true,
|
||||||
serverId: true,
|
applicationStatus: true,
|
||||||
applicationStatus: true,
|
} as const;
|
||||||
} as const;
|
|
||||||
|
|
||||||
|
export const findProjectById = async (projectId: string) => {
|
||||||
const project = await db.query.projects.findFirst({
|
const project = await db.query.projects.findFirst({
|
||||||
where: eq(projects.projectId, projectId),
|
where: eq(projects.projectId, projectId),
|
||||||
with: {
|
with: {
|
||||||
|
|||||||
Reference in New Issue
Block a user