From 7653eda8b3c9fa5e3fb397cea7d8d22bbcac1fb1 Mon Sep 17 00:00:00 2001 From: Matthias Rupp Date: Mon, 21 Nov 2022 20:17:44 +0100 Subject: [PATCH] Clean up --- .../apps/immich/src/api-v1/album/album.service.spec.ts | 2 ++ .../apps/immich/src/api-v1/asset/asset.controller.ts | 2 -- server/apps/immich/src/api-v1/asset/asset.module.ts | 10 +++++----- server/apps/immich/src/api-v1/asset/asset.service.ts | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/server/apps/immich/src/api-v1/album/album.service.spec.ts b/server/apps/immich/src/api-v1/album/album.service.spec.ts index 30153795f2..adfcff13fd 100644 --- a/server/apps/immich/src/api-v1/album/album.service.spec.ts +++ b/server/apps/immich/src/api-v1/album/album.service.spec.ts @@ -123,6 +123,7 @@ describe('Album service', () => { updateAlbum: jest.fn(), getListByAssetId: jest.fn(), getCountByUserId: jest.fn(), + getSharedAlbumCount: jest.fn(), }; assetRepositoryMock = { @@ -142,6 +143,7 @@ describe('Album service', () => { getAssetWithNoThumbnail: jest.fn(), getAssetWithNoSmartInfo: jest.fn(), getExistingAssets: jest.fn(), + countByIdAndUser: jest.fn(), }; downloadServiceMock = { diff --git a/server/apps/immich/src/api-v1/asset/asset.controller.ts b/server/apps/immich/src/api-v1/asset/asset.controller.ts index 03280d88df..f070fe6415 100644 --- a/server/apps/immich/src/api-v1/asset/asset.controller.ts +++ b/server/apps/immich/src/api-v1/asset/asset.controller.ts @@ -14,8 +14,6 @@ import { Header, Put, UploadedFiles, - HttpException, - HttpStatus } from '@nestjs/common'; import { Authenticated } from '../../decorators/authenticated.decorator'; import { AssetService } from './asset.service'; diff --git a/server/apps/immich/src/api-v1/asset/asset.module.ts b/server/apps/immich/src/api-v1/asset/asset.module.ts index 698fc46ba3..d6d3b98196 100644 --- a/server/apps/immich/src/api-v1/asset/asset.module.ts +++ b/server/apps/immich/src/api-v1/asset/asset.module.ts @@ -10,11 +10,11 @@ import { CommunicationModule } from '../communication/communication.module'; import { QueueNameEnum } from '@app/job/constants/queue-name.constant'; import { AssetRepository, ASSET_REPOSITORY } from './asset-repository'; import { DownloadModule } from '../../modules/download/download.module'; -import {ALBUM_REPOSITORY, AlbumRepository} from "../album/album-repository"; -import {AlbumEntity} from "@app/database/entities/album.entity"; -import {UserAlbumEntity} from "@app/database/entities/user-album.entity"; -import {UserEntity} from "@app/database/entities/user.entity"; -import {AssetAlbumEntity} from "@app/database/entities/asset-album.entity"; +import { ALBUM_REPOSITORY, AlbumRepository } from '../album/album-repository'; +import { AlbumEntity } from '@app/database/entities/album.entity'; +import { UserAlbumEntity } from '@app/database/entities/user-album.entity'; +import { UserEntity } from '@app/database/entities/user.entity'; +import { AssetAlbumEntity } from '@app/database/entities/asset-album.entity'; @Module({ imports: [ diff --git a/server/apps/immich/src/api-v1/asset/asset.service.ts b/server/apps/immich/src/api-v1/asset/asset.service.ts index 50a8548d6f..7d8d5dde28 100644 --- a/server/apps/immich/src/api-v1/asset/asset.service.ts +++ b/server/apps/immich/src/api-v1/asset/asset.service.ts @@ -54,7 +54,7 @@ import { InjectQueue } from '@nestjs/bull'; import { Queue } from 'bull'; import { DownloadService } from '../../modules/download/download.service'; import { DownloadDto } from './dto/download-library.dto'; -import { ALBUM_REPOSITORY, IAlbumRepository } from "../album/album-repository"; +import { ALBUM_REPOSITORY, IAlbumRepository } from '../album/album-repository'; const fileInfo = promisify(stat); @@ -634,14 +634,14 @@ export class AssetService { async checkAssetsAccess(authUser: AuthUserDto, assetIds: string[], mustBeOwner = false) { for (const assetId of assetIds) { // Step 1: Check if user owns asset - if (await this._assetRepository.countByIdAndUser(assetId, authUser.id) == 1) { + if ((await this._assetRepository.countByIdAndUser(assetId, authUser.id)) == 1) { continue; } // Avoid additional checks if ownership is required if (!mustBeOwner) { // Step 2: Check if asset is part of an album shared with me - if (await this._albumRepository.getSharedAlbumCount(authUser.id, assetId) > 0) { + if ((await this._albumRepository.getSharedAlbumCount(authUser.id, assetId)) > 0) { continue; }