(core) Add unquarantine command to admin CLI

Summary:
Adds a CLI command to un-quarantine an active document. Also tweaks the
name of related environment variable to avoid a naming conflict.

Test Plan: Server test.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D3583
This commit is contained in:
George Gevoian
2022-08-15 12:52:38 -07:00
parent 103c795aa2
commit 0c5441b176
4 changed files with 23 additions and 6 deletions

View File

@@ -601,12 +601,17 @@ export class DocWorkerApi {
// is freed up for reassignment, otherwise false.
//
// Optionally accepts a `group` query param for updating the document's group prior
// to (possible) reassignment. (Note: Requires special permit.)
// to (possible) reassignment. A blank string unsets the current group, if any.
// (Requires a special permit.)
this._app.post('/api/docs/:docId/assign', canEdit, throttled(async (req, res) => {
const docId = getDocId(req);
const group = optStringParam(req.query.group);
if (group && req.specialPermit?.action === 'assign-doc') {
await this._docWorkerMap.updateDocGroup(docId, group);
if (group !== undefined && req.specialPermit?.action === 'assign-doc') {
if (group.trim() === '') {
await this._docWorkerMap.removeDocGroup(docId);
} else {
await this._docWorkerMap.updateDocGroup(docId, group);
}
}
const status = await this._docWorkerMap.getDocWorker(docId);
if (!status) { res.json(false); return; }

View File

@@ -66,8 +66,12 @@ export interface IDocWorkerMap extends IPermitStores, IElectionStore, IChecksumS
getAssignments(workerId: string): Promise<string[]>;
getWorkerGroup(workerId: string): Promise<string|null>;
getDocGroup(docId: string): Promise<string|null>;
updateDocGroup(docId: string, docGroup: string): Promise<void>;
removeDocGroup(docId: string): Promise<void>;
getRedisClient(): RedisClient|null;
}