Skip to content

Commit

Permalink
Partial revert PR: #324
Browse files Browse the repository at this point in the history
justified by plan to change the thumbnail of logbook to the file hash
rather than the id
  • Loading branch information
minottic committed Feb 2, 2024
1 parent 8fa50d8 commit f9f79a7
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
});
});
10 changes: 2 additions & 8 deletions sci-log-db/src/mixins/basesnippet.repository-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,11 @@ function UpdateAndDeleteRepositoryMixin<
): Promise<void> {
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) &&
Expand Down Expand Up @@ -160,6 +153,7 @@ function UpdateAndDeleteRepositoryMixin<
}

private isSharing(patches: Partial<Basesnippet>) {
if (Object.keys(patches).length === 0) return false;
return Object.keys(patches).every(d =>
this.expandedACLS.includes(d as typeof this.expandedACLS[number]),
);
Expand Down
6 changes: 0 additions & 6 deletions sci-log-db/src/models/logbook.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f9f79a7

Please sign in to comment.