From 587da4db97b8f939ef9b20a4bdedfec2289fa78e Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Mon, 25 Jan 2021 12:05:57 -0500 Subject: [PATCH] (core) provide a way for an administrator to force reload of a document Summary: Adds POST /api/housekeeping/docs/:docId/force-reload, which allows the support user to force a document to reload (even if they don't otherwise have access to the document). This could be done without a separate endpoint, but that turned out a bit messy, and there's some advantage to quarantining the exceptional authorization somewhere it could be easily elaborated. Test Plan: adds test Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2713 --- app/gen-server/lib/Housekeeper.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/gen-server/lib/Housekeeper.ts b/app/gen-server/lib/Housekeeper.ts index 10e836ee..e7d39436 100644 --- a/app/gen-server/lib/Housekeeper.ts +++ b/app/gen-server/lib/Housekeeper.ts @@ -151,6 +151,16 @@ export class Housekeeper { headers, }); })); + + // Force a document to reload. Can be useful during administrative + // actions. + app.post('/api/housekeeping/docs/:docId/force-reload', this._withSupport(async (docId, headers) => { + const url = await this._server.getHomeUrlByDocId(docId, `/api/docs/${docId}/force-reload`); + return fetch(url, { + method: 'POST', + headers, + }); + })); } /**