mirror of
https://github.com/outline/outline.git
synced 2026-05-07 18:41:12 -05:00
Add revision deletion endpoints (#9240)
This commit is contained in:
@@ -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
|
||||
|
||||
/**
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user