diff --git a/server/models/Document.js b/server/models/Document.js index 8b60238681..ca590d5962 100644 --- a/server/models/Document.js +++ b/server/models/Document.js @@ -674,7 +674,7 @@ Document.prototype.unarchive = async function (userId: string) { return this; }; -Document.prototype.restore = async function ( +Document.prototype.restoreFromRevision = async function ( revision: Revision, userId: string ) { @@ -685,7 +685,9 @@ Document.prototype.restore = async function ( this.text = revision.text; this.title = revision.title; this.lastModifiedById = userId; - return await this.save(); + await this.save(); + + return this; }; // Delete a document, archived or otherwise. diff --git a/server/routes/api/documents.js b/server/routes/api/documents.js index ec86d15209..ff45e7d956 100644 --- a/server/routes/api/documents.js +++ b/server/routes/api/documents.js @@ -713,7 +713,7 @@ router.post("documents.restore", auth(), async (ctx) => { const revision = await Revision.findByPk(revisionId); authorize(document, "restore", revision); - await document.restore(revision, user.id); + await document.restoreFromRevision(revision, user.id); await Event.create({ name: "documents.restore",