From 86473f96ce5027e2dacf528280de68eca48595fc Mon Sep 17 00:00:00 2001 From: Kristina Date: Wed, 24 Sep 2025 23:44:36 +0400 Subject: [PATCH] Use safe remove (#106) Signed-off-by: Kristina Fefelova --- packages/server/src/blob.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/server/src/blob.ts b/packages/server/src/blob.ts index a2f95dd1be..47dc6ef935 100644 --- a/packages/server/src/blob.ts +++ b/packages/server/src/blob.ts @@ -336,8 +336,9 @@ export class Blob { async removeMessage (cardId: CardID, blobId: BlobID, messageId: MessageID): Promise { const patches: JsonPatch[] = [ { - op: 'remove', - path: `/messages/${messageId}` + hop: 'remove', + path: `/messages/${messageId}`, + safe: true } as const ] @@ -369,8 +370,9 @@ export class Blob { async removeReaction (cardId: CardID, blobId: BlobID, messageId: MessageID, emoji: string, person: PersonUuid): Promise { const patches: JsonPatch[] = [ { - op: 'remove', - path: `/messages/${messageId}/reactions/${emoji}/${person}` + hop: 'remove', + path: `/messages/${messageId}/reactions/${emoji}/${person}`, + safe: true } ] await this.patchJson(cardId, blobId, patches) @@ -394,8 +396,9 @@ export class Blob { for (const attachmentId of attachmentIds) { patches.push({ - op: 'remove', - path: `/messages/${messageId}/attachments/${attachmentId}` + hop: 'remove', + path: `/messages/${messageId}/attachments/${attachmentId}`, + safe: true }) } await this.patchJson(cardId, blobId, patches) @@ -506,8 +509,9 @@ export class Blob { async removeThread (cardId: CardID, blobId: BlobID, messageId: MessageID, threadId: CardID): Promise { const patches: JsonPatch[] = [ { - op: 'remove', - path: `/messages/${messageId}/threads/${threadId}` + hop: 'remove', + path: `/messages/${messageId}/threads/${threadId}`, + safe: true } ] await this.patchJson(cardId, blobId, patches)