From f9f79a7c5a2670185ac84e2f78f90b6278574218 Mon Sep 17 00:00:00 2001 From: minottic Date: Fri, 2 Feb 2024 15:34:39 +0100 Subject: [PATCH] Partial revert PR: #324 justified by plan to change the thumbnail of logbook to the file hash rather than the id --- .../logbook.controller.acceptance.ts | 21 ------------------- .../mixins/basesnippet.repository-mixin.ts | 10 ++------- sci-log-db/src/models/logbook.model.ts | 6 ------ 3 files changed, 2 insertions(+), 35 deletions(-) diff --git a/sci-log-db/src/__tests__/acceptance/logbook.controller.acceptance.ts b/sci-log-db/src/__tests__/acceptance/logbook.controller.acceptance.ts index a730d487..02d27f40 100644 --- a/sci-log-db/src/__tests__/acceptance/logbook.controller.acceptance.ts +++ b/sci-log-db/src/__tests__/acceptance/logbook.controller.acceptance.ts @@ -511,25 +511,4 @@ describe('Logbook', function (this: Suite) { throw err; }); }); - - it('add thumbnail hash when editing logbook', async () => { - const file = await client - .post(`/filesnippet`) - .set('Authorization', 'Bearer ' + token) - .set('Content-Type', 'application/json') - .send({accessHash: 'hash', readACL: [logbookSnippet.ownerGroup]}) - .expect(200); - await client - .patch(`/logbooks/${logbookSnippetId}`) - .set('Authorization', 'Bearer ' + token) - .set('Content-Type', 'application/json') - .send({thumbnail: file.body.id}) - .expect(204); - await client - .get(`/logbooks/${logbookSnippetId}`) - .set('Authorization', 'Bearer ' + token) - .set('Content-Type', 'application/json') - .expect(200) - .then(result => expect(result.body.thumbnailHash).to.eql('hash')); - }); }); diff --git a/sci-log-db/src/mixins/basesnippet.repository-mixin.ts b/sci-log-db/src/mixins/basesnippet.repository-mixin.ts index 39563049..1ca9d5bf 100644 --- a/sci-log-db/src/mixins/basesnippet.repository-mixin.ts +++ b/sci-log-db/src/mixins/basesnippet.repository-mixin.ts @@ -61,18 +61,11 @@ function UpdateAndDeleteRepositoryMixin< ): Promise { const baseSnippetRepository = await this.baseSnippetRepository(); const snippet = await baseSnippetRepository.findById(id, {}, options); - if (basesnippet.thumbnail && !basesnippet.thumbnailHash) - basesnippet.thumbnailHash = ( - await baseSnippetRepository.findById( - basesnippet.thumbnail, - {}, - options, - ) - ).accessHash; const patches = await this.applyFromOwnerAccessAndGetChanged( basesnippet, snippet, ); + if (Object.keys(patches).length === 0) return; if (!basesnippet.deleted) { if ( !this.isSharing(patches) && @@ -160,6 +153,7 @@ function UpdateAndDeleteRepositoryMixin< } private isSharing(patches: Partial) { + if (Object.keys(patches).length === 0) return false; return Object.keys(patches).every(d => this.expandedACLS.includes(d as typeof this.expandedACLS[number]), ); diff --git a/sci-log-db/src/models/logbook.model.ts b/sci-log-db/src/models/logbook.model.ts index 024a3bd5..076dfb45 100644 --- a/sci-log-db/src/models/logbook.model.ts +++ b/sci-log-db/src/models/logbook.model.ts @@ -37,12 +37,6 @@ export class Logbook extends Basesnippet { }) thumbnail?: string; - @property({ - type: 'string', - description: 'Optional hash of the image/logo associated to this logbook', - }) - thumbnailHash?: string; - @property({ type: 'string', required: true,