Add revision deletion endpoints (#9240)

This commit is contained in:
Tom Moor
2025-05-21 22:57:02 -04:00
committed by GitHub
parent 22c0f18b6b
commit 3ffee1239b
16 changed files with 185 additions and 147 deletions
+13 -3
View File
@@ -13,12 +13,13 @@ import {
Table,
IsNumeric,
Length as SimpleLength,
BeforeDestroy,
} from "sequelize-typescript";
import type { ProsemirrorData } from "@shared/types";
import { DocumentValidation, RevisionValidation } from "@shared/validations";
import Document from "./Document";
import User from "./User";
import IdModel from "./base/IdModel";
import ParanoidModel from "./base/ParanoidModel";
import Fix from "./decorators/Fix";
import IsHexColor from "./validators/IsHexColor";
import Length from "./validators/Length";
@@ -34,7 +35,7 @@ import Length from "./validators/Length";
}))
@Table({ tableName: "revisions", modelName: "revision" })
@Fix
class Revision extends IdModel<
class Revision extends ParanoidModel<
InferAttributes<Revision>,
Partial<InferCreationAttributes<Revision>>
> {
@@ -74,7 +75,7 @@ class Revision extends IdModel<
* and is no longer being written.
*/
@Column(DataType.TEXT)
text: string;
text: string | null;
/** The content of the revision as JSON. */
@Column(DataType.JSONB)
@@ -109,6 +110,15 @@ class Revision extends IdModel<
@Column(DataType.UUID)
userId: string;
// hooks
@BeforeDestroy
static async clearData(model: Revision) {
model.content = null;
model.text = null;
model.title = "";
}
// static methods
/**
+1 -1
View File
@@ -104,7 +104,7 @@ export class DocumentHelper {
} else if (document instanceof Collection) {
doc = parser.parse(document.description ?? "");
} else {
doc = parser.parse(document.text);
doc = parser.parse(document.text ?? "");
}
if (doc && options?.signedUrls && options?.teamId) {