fix(server): only return workspace user fields (#10700)
close CLOUD-164
This commit is contained in:
@@ -5,3 +5,10 @@ export const publicUserSelect = {
|
|||||||
name: true,
|
name: true,
|
||||||
avatarUrl: true,
|
avatarUrl: true,
|
||||||
} satisfies Prisma.UserSelect;
|
} satisfies Prisma.UserSelect;
|
||||||
|
|
||||||
|
export const workspaceUserSelect = {
|
||||||
|
id: true,
|
||||||
|
name: true,
|
||||||
|
email: true,
|
||||||
|
avatarUrl: true,
|
||||||
|
} satisfies Prisma.UserSelect;
|
||||||
|
|||||||
@@ -11,21 +11,9 @@ import {
|
|||||||
WrongSignInMethod,
|
WrongSignInMethod,
|
||||||
} from '../base';
|
} from '../base';
|
||||||
import { BaseModel } from './base';
|
import { BaseModel } from './base';
|
||||||
import { WorkspaceRole } from './common';
|
import { publicUserSelect, WorkspaceRole, workspaceUserSelect } from './common';
|
||||||
import type { Workspace } from './workspace';
|
import type { Workspace } from './workspace';
|
||||||
|
|
||||||
const publicUserSelect = {
|
|
||||||
id: true,
|
|
||||||
name: true,
|
|
||||||
avatarUrl: true,
|
|
||||||
} satisfies Prisma.UserSelect;
|
|
||||||
const workspaceUserSelect = {
|
|
||||||
id: true,
|
|
||||||
name: true,
|
|
||||||
email: true,
|
|
||||||
avatarUrl: true,
|
|
||||||
} satisfies Prisma.UserSelect;
|
|
||||||
|
|
||||||
type CreateUserInput = Omit<Prisma.UserCreateInput, 'name'> & { name?: string };
|
type CreateUserInput = Omit<Prisma.UserCreateInput, 'name'> & { name?: string };
|
||||||
type UpdateUserInput = Omit<Partial<Prisma.UserCreateInput>, 'id'>;
|
type UpdateUserInput = Omit<Partial<Prisma.UserCreateInput>, 'id'>;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { groupBy } from 'lodash-es';
|
|||||||
|
|
||||||
import { EventBus, PaginationInput } from '../base';
|
import { EventBus, PaginationInput } from '../base';
|
||||||
import { BaseModel } from './base';
|
import { BaseModel } from './base';
|
||||||
import { WorkspaceRole } from './common';
|
import { WorkspaceRole, workspaceUserSelect } from './common';
|
||||||
|
|
||||||
export { WorkspaceMemberStatus };
|
export { WorkspaceMemberStatus };
|
||||||
|
|
||||||
@@ -236,7 +236,9 @@ export class WorkspaceUserModel extends BaseModel {
|
|||||||
async getOwner(workspaceId: string) {
|
async getOwner(workspaceId: string) {
|
||||||
const role = await this.db.workspaceUserRole.findFirst({
|
const role = await this.db.workspaceUserRole.findFirst({
|
||||||
include: {
|
include: {
|
||||||
user: true,
|
user: {
|
||||||
|
select: workspaceUserSelect,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
workspaceId,
|
workspaceId,
|
||||||
@@ -254,7 +256,9 @@ export class WorkspaceUserModel extends BaseModel {
|
|||||||
async getAdmins(workspaceId: string) {
|
async getAdmins(workspaceId: string) {
|
||||||
const list = await this.db.workspaceUserRole.findMany({
|
const list = await this.db.workspaceUserRole.findMany({
|
||||||
include: {
|
include: {
|
||||||
user: true,
|
user: {
|
||||||
|
select: workspaceUserSelect,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
workspaceId,
|
workspaceId,
|
||||||
@@ -291,7 +295,9 @@ export class WorkspaceUserModel extends BaseModel {
|
|||||||
return await Promise.all([
|
return await Promise.all([
|
||||||
this.db.workspaceUserRole.findMany({
|
this.db.workspaceUserRole.findMany({
|
||||||
include: {
|
include: {
|
||||||
user: true,
|
user: {
|
||||||
|
select: workspaceUserSelect,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
where: {
|
where: {
|
||||||
workspaceId,
|
workspaceId,
|
||||||
@@ -317,7 +323,7 @@ export class WorkspaceUserModel extends BaseModel {
|
|||||||
pagination: PaginationInput
|
pagination: PaginationInput
|
||||||
) {
|
) {
|
||||||
return await this.db.workspaceUserRole.findMany({
|
return await this.db.workspaceUserRole.findMany({
|
||||||
include: { user: true },
|
include: { user: { select: workspaceUserSelect } },
|
||||||
where: {
|
where: {
|
||||||
workspaceId,
|
workspaceId,
|
||||||
status: WorkspaceMemberStatus.Accepted,
|
status: WorkspaceMemberStatus.Accepted,
|
||||||
|
|||||||
Reference in New Issue
Block a user