From dc504339b52fac284bf69940dff8834ba04ccfad Mon Sep 17 00:00:00 2001 From: Alexey Zinoviev Date: Sun, 9 Nov 2025 23:46:08 +0400 Subject: [PATCH] Qfix: double approval of review/approve request Signed-off-by: Alexey Zinoviev --- plugins/controlled-documents-resources/src/utils.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/controlled-documents-resources/src/utils.ts b/plugins/controlled-documents-resources/src/utils.ts index 95285b670ad..2da76d330e4 100644 --- a/plugins/controlled-documents-resources/src/utils.ts +++ b/plugins/controlled-documents-resources/src/utils.ts @@ -443,11 +443,22 @@ export async function completeRequest ( return } - await client.update(req, { + const ops = client.apply(req._id) + + // Check on the server side if the user has already approved - do not add the second time + // otherwise request is never finished and ends up in a broken state + ops.notMatch(reqClass, { + _id: req._id, + approved: me + }) + + await ops.update(req, { $push: { approved: me } }) + + await ops.commit() } export async function saveComment (message: Markup | undefined, req: DocumentRequest): Promise {