mirror of
https://github.com/documenso/documenso.git
synced 2025-11-16 09:41:35 +10:00
Compare commits
1 Commits
0bbd9aa9a1
...
v1.12.3
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ecfdbdde5 |
@ -101,5 +101,5 @@
|
|||||||
"vite-plugin-babel-macros": "^1.0.6",
|
"vite-plugin-babel-macros": "^1.0.6",
|
||||||
"vite-tsconfig-paths": "^5.1.4"
|
"vite-tsconfig-paths": "^5.1.4"
|
||||||
},
|
},
|
||||||
"version": "1.12.2-rc.6"
|
"version": "1.12.3"
|
||||||
}
|
}
|
||||||
|
|||||||
6
package-lock.json
generated
6
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@documenso/root",
|
"name": "@documenso/root",
|
||||||
"version": "1.12.2-rc.6",
|
"version": "1.12.3",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@documenso/root",
|
"name": "@documenso/root",
|
||||||
"version": "1.12.2-rc.6",
|
"version": "1.12.3",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"apps/*",
|
"apps/*",
|
||||||
"packages/*"
|
"packages/*"
|
||||||
@ -89,7 +89,7 @@
|
|||||||
},
|
},
|
||||||
"apps/remix": {
|
"apps/remix": {
|
||||||
"name": "@documenso/remix",
|
"name": "@documenso/remix",
|
||||||
"version": "1.12.2-rc.6",
|
"version": "1.12.3",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@documenso/api": "*",
|
"@documenso/api": "*",
|
||||||
"@documenso/assets": "*",
|
"@documenso/assets": "*",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.12.2-rc.6",
|
"version": "1.12.3",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "turbo run build",
|
"build": "turbo run build",
|
||||||
"dev": "turbo run dev --filter=@documenso/remix",
|
"dev": "turbo run dev --filter=@documenso/remix",
|
||||||
|
|||||||
@ -1,84 +0,0 @@
|
|||||||
import { deletedAccountServiceAccount } from '@documenso/lib/server-only/user/service-accounts/deleted-account';
|
|
||||||
import { prisma } from '@documenso/prisma';
|
|
||||||
import { DocumentStatus } from '@documenso/prisma/client';
|
|
||||||
|
|
||||||
type HandleDocumentOwnershipOnDeletionOptions = {
|
|
||||||
documentIds: number[];
|
|
||||||
organisationOwnerId: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const handleDocumentOwnershipOnDeletion = async ({
|
|
||||||
documentIds,
|
|
||||||
organisationOwnerId,
|
|
||||||
}: HandleDocumentOwnershipOnDeletionOptions) => {
|
|
||||||
if (documentIds.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const serviceAccount = await deletedAccountServiceAccount();
|
|
||||||
const serviceAccountTeam = serviceAccount.ownedOrganisations[0].teams[0];
|
|
||||||
|
|
||||||
await prisma.document.deleteMany({
|
|
||||||
where: {
|
|
||||||
id: {
|
|
||||||
in: documentIds,
|
|
||||||
},
|
|
||||||
status: DocumentStatus.DRAFT,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const organisationOwner = await prisma.user.findUnique({
|
|
||||||
where: {
|
|
||||||
id: organisationOwnerId,
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
ownedOrganisations: {
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
teams: {
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (organisationOwner && organisationOwner.ownedOrganisations.length > 0) {
|
|
||||||
const ownerPersonalTeam = organisationOwner.ownedOrganisations[0].teams[0];
|
|
||||||
|
|
||||||
await prisma.document.updateMany({
|
|
||||||
where: {
|
|
||||||
id: {
|
|
||||||
in: documentIds,
|
|
||||||
},
|
|
||||||
status: {
|
|
||||||
in: [DocumentStatus.PENDING, DocumentStatus.REJECTED, DocumentStatus.COMPLETED],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
userId: organisationOwner.id,
|
|
||||||
teamId: ownerPersonalTeam.id,
|
|
||||||
deletedAt: new Date(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await prisma.document.updateMany({
|
|
||||||
where: {
|
|
||||||
id: {
|
|
||||||
in: documentIds,
|
|
||||||
},
|
|
||||||
status: {
|
|
||||||
in: [DocumentStatus.PENDING, DocumentStatus.REJECTED, DocumentStatus.COMPLETED],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
userId: serviceAccount.id,
|
|
||||||
teamId: serviceAccountTeam.id,
|
|
||||||
deletedAt: new Date(),
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@ -5,20 +5,6 @@ export const deletedAccountServiceAccount = async () => {
|
|||||||
where: {
|
where: {
|
||||||
email: 'deleted-account@documenso.com',
|
email: 'deleted-account@documenso.com',
|
||||||
},
|
},
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
email: true,
|
|
||||||
ownedOrganisations: {
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
teams: {
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!serviceAccount) {
|
if (!serviceAccount) {
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import {
|
|||||||
ORGANISATION_USER_ACCOUNT_TYPE,
|
ORGANISATION_USER_ACCOUNT_TYPE,
|
||||||
} from '@documenso/lib/constants/organisations';
|
} from '@documenso/lib/constants/organisations';
|
||||||
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
||||||
import { handleDocumentOwnershipOnDeletion } from '@documenso/lib/server-only/document/handle-document-ownership-on-deletion';
|
|
||||||
import { buildOrganisationWhereQuery } from '@documenso/lib/utils/organisations';
|
import { buildOrganisationWhereQuery } from '@documenso/lib/utils/organisations';
|
||||||
import { prisma } from '@documenso/prisma';
|
import { prisma } from '@documenso/prisma';
|
||||||
|
|
||||||
@ -33,24 +32,6 @@ export const deleteOrganisationRoute = authenticatedProcedure
|
|||||||
userId: user.id,
|
userId: user.id,
|
||||||
roles: ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP['DELETE_ORGANISATION'],
|
roles: ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP['DELETE_ORGANISATION'],
|
||||||
}),
|
}),
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
owner: {
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
teams: {
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
documents: {
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!organisation) {
|
if (!organisation) {
|
||||||
@ -59,15 +40,6 @@ export const deleteOrganisationRoute = authenticatedProcedure
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const documentIds = organisation.teams.flatMap((team) => team.documents.map((doc) => doc.id));
|
|
||||||
|
|
||||||
if (documentIds && documentIds.length > 0) {
|
|
||||||
await handleDocumentOwnershipOnDeletion({
|
|
||||||
documentIds,
|
|
||||||
organisationOwnerId: organisation.owner.id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
await prisma.$transaction(async (tx) => {
|
await prisma.$transaction(async (tx) => {
|
||||||
await tx.account.deleteMany({
|
await tx.account.deleteMany({
|
||||||
where: {
|
where: {
|
||||||
|
|||||||
@ -1,8 +1,4 @@
|
|||||||
import { ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP } from '@documenso/lib/constants/organisations';
|
|
||||||
import { handleDocumentOwnershipOnDeletion } from '@documenso/lib/server-only/document/handle-document-ownership-on-deletion';
|
|
||||||
import { deleteTeam } from '@documenso/lib/server-only/team/delete-team';
|
import { deleteTeam } from '@documenso/lib/server-only/team/delete-team';
|
||||||
import { buildOrganisationWhereQuery } from '@documenso/lib/utils/organisations';
|
|
||||||
import { prisma } from '@documenso/prisma';
|
|
||||||
|
|
||||||
import { authenticatedProcedure } from '../trpc';
|
import { authenticatedProcedure } from '../trpc';
|
||||||
import { ZDeleteTeamRequestSchema, ZDeleteTeamResponseSchema } from './delete-team.types';
|
import { ZDeleteTeamRequestSchema, ZDeleteTeamResponseSchema } from './delete-team.types';
|
||||||
@ -15,53 +11,12 @@ export const deleteTeamRoute = authenticatedProcedure
|
|||||||
const { teamId } = input;
|
const { teamId } = input;
|
||||||
const { user } = ctx;
|
const { user } = ctx;
|
||||||
|
|
||||||
const team = await prisma.team.findUnique({
|
|
||||||
where: {
|
|
||||||
id: teamId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const organisation = await prisma.organisation.findFirst({
|
|
||||||
where: buildOrganisationWhereQuery({
|
|
||||||
organisationId: team?.organisationId,
|
|
||||||
userId: user.id,
|
|
||||||
roles: ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP['DELETE_ORGANISATION'],
|
|
||||||
}),
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
owner: {
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
teams: {
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
documents: {
|
|
||||||
select: {
|
|
||||||
id: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
ctx.logger.info({
|
ctx.logger.info({
|
||||||
input: {
|
input: {
|
||||||
teamId,
|
teamId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const documentIds = organisation?.teams.flatMap((team) => team.documents.map((doc) => doc.id));
|
|
||||||
|
|
||||||
if (documentIds && documentIds.length > 0 && organisation) {
|
|
||||||
await handleDocumentOwnershipOnDeletion({
|
|
||||||
documentIds,
|
|
||||||
organisationOwnerId: organisation.owner.id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
await deleteTeam({
|
await deleteTeam({
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
teamId,
|
teamId,
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import type { HTMLAttributes } from 'react';
|
import type { HTMLAttributes } from 'react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
import { Trans } from '@lingui/react/macro';
|
|
||||||
import { KeyboardIcon, UploadCloudIcon } from 'lucide-react';
|
import { KeyboardIcon, UploadCloudIcon } from 'lucide-react';
|
||||||
import { match } from 'ts-pattern';
|
import { match } from 'ts-pattern';
|
||||||
|
import { Trans } from '@lingui/react/macro';
|
||||||
|
|
||||||
import { DocumentSignatureType } from '@documenso/lib/constants/document';
|
import { DocumentSignatureType } from '@documenso/lib/constants/document';
|
||||||
import { isBase64Image } from '@documenso/lib/constants/signatures';
|
import { isBase64Image } from '@documenso/lib/constants/signatures';
|
||||||
|
|||||||
@ -216,12 +216,7 @@ export const AddTemplateSettingsFormPartial = ({
|
|||||||
</FormLabel>
|
</FormLabel>
|
||||||
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input className="bg-background" {...field} maxLength={255} onBlur={handleAutoSave} />
|
||||||
className="bg-background"
|
|
||||||
{...field}
|
|
||||||
maxLength={255}
|
|
||||||
onBlur={handleAutoSave}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@ -629,12 +624,7 @@ export const AddTemplateSettingsFormPartial = ({
|
|||||||
</FormLabel>
|
</FormLabel>
|
||||||
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input className="bg-background" {...field} maxLength={255} onBlur={handleAutoSave} />
|
||||||
className="bg-background"
|
|
||||||
{...field}
|
|
||||||
maxLength={255}
|
|
||||||
onBlur={handleAutoSave}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
@ -725,12 +715,7 @@ export const AddTemplateSettingsFormPartial = ({
|
|||||||
</FormLabel>
|
</FormLabel>
|
||||||
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input
|
<Input className="bg-background" {...field} maxLength={255} onBlur={handleAutoSave} />
|
||||||
className="bg-background"
|
|
||||||
{...field}
|
|
||||||
maxLength={255}
|
|
||||||
onBlur={handleAutoSave}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
|
|||||||
Reference in New Issue
Block a user