From b680a3e15219f7ec4b57df8a337ef943fe3886cb Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 27 Oct 2021 22:52:30 -0700 Subject: [PATCH] avoid overriding restore --- server/models/Document.js | 6 ++++-- server/routes/api/documents.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) 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",