forked from Cutlery/immich
		
	replace legacy enum
This commit is contained in:
		
							parent
							
								
									d451abd96c
								
							
						
					
					
						commit
						7e07b74406
					
				@ -2,6 +2,7 @@ import { ApiProperty } from '@nestjs/swagger';
 | 
				
			|||||||
import { Type } from 'class-transformer';
 | 
					import { Type } from 'class-transformer';
 | 
				
			||||||
import { ArrayNotEmpty, IsArray, IsEnum, IsInt, IsNotEmpty, IsString, IsUUID, ValidateNested } from 'class-validator';
 | 
					import { ArrayNotEmpty, IsArray, IsEnum, IsInt, IsNotEmpty, IsString, IsUUID, ValidateNested } from 'class-validator';
 | 
				
			||||||
import { UploadFieldName } from 'src/dtos/asset.dto';
 | 
					import { UploadFieldName } from 'src/dtos/asset.dto';
 | 
				
			||||||
 | 
					import { ImageFormat } from 'src/entities/system-config.entity';
 | 
				
			||||||
import { Optional, ValidateBoolean, ValidateDate, ValidateUUID } from 'src/validation';
 | 
					import { Optional, ValidateBoolean, ValidateDate, ValidateUUID } from 'src/validation';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class AssetBulkUploadCheckItem {
 | 
					export class AssetBulkUploadCheckItem {
 | 
				
			||||||
@ -112,22 +113,17 @@ export class CreateAssetDto {
 | 
				
			|||||||
  [UploadFieldName.SIDECAR_DATA]?: any;
 | 
					  [UploadFieldName.SIDECAR_DATA]?: any;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export enum GetAssetThumbnailFormatEnum {
 | 
					 | 
				
			||||||
  JPEG = 'JPEG',
 | 
					 | 
				
			||||||
  WEBP = 'WEBP',
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export class GetAssetThumbnailDto {
 | 
					export class GetAssetThumbnailDto {
 | 
				
			||||||
  @Optional()
 | 
					  @Optional()
 | 
				
			||||||
  @IsEnum(GetAssetThumbnailFormatEnum)
 | 
					  @IsEnum(ImageFormat)
 | 
				
			||||||
  @ApiProperty({
 | 
					  @ApiProperty({
 | 
				
			||||||
    type: String,
 | 
					    type: String,
 | 
				
			||||||
    enum: GetAssetThumbnailFormatEnum,
 | 
					    enum: ImageFormat,
 | 
				
			||||||
    default: GetAssetThumbnailFormatEnum.WEBP,
 | 
					    default: ImageFormat.WEBP,
 | 
				
			||||||
    required: false,
 | 
					    required: false,
 | 
				
			||||||
    enumName: 'ThumbnailFormat',
 | 
					    enumName: 'ThumbnailFormat',
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
  format: GetAssetThumbnailFormatEnum = GetAssetThumbnailFormatEnum.WEBP;
 | 
					  format: ImageFormat = ImageFormat.WEBP;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class SearchPropertiesDto {
 | 
					export class SearchPropertiesDto {
 | 
				
			||||||
 | 
				
			|||||||
@ -22,12 +22,12 @@ import {
 | 
				
			|||||||
  CheckExistingAssetsDto,
 | 
					  CheckExistingAssetsDto,
 | 
				
			||||||
  CreateAssetDto,
 | 
					  CreateAssetDto,
 | 
				
			||||||
  GetAssetThumbnailDto,
 | 
					  GetAssetThumbnailDto,
 | 
				
			||||||
  GetAssetThumbnailFormatEnum,
 | 
					 | 
				
			||||||
  ServeFileDto,
 | 
					  ServeFileDto,
 | 
				
			||||||
} from 'src/dtos/asset-v1.dto';
 | 
					} from 'src/dtos/asset-v1.dto';
 | 
				
			||||||
import { AuthDto } from 'src/dtos/auth.dto';
 | 
					import { AuthDto } from 'src/dtos/auth.dto';
 | 
				
			||||||
import { ASSET_CHECKSUM_CONSTRAINT, AssetEntity, AssetType } from 'src/entities/asset.entity';
 | 
					import { ASSET_CHECKSUM_CONSTRAINT, AssetEntity, AssetType } from 'src/entities/asset.entity';
 | 
				
			||||||
import { LibraryType } from 'src/entities/library.entity';
 | 
					import { LibraryType } from 'src/entities/library.entity';
 | 
				
			||||||
 | 
					import { ImageFormat } from 'src/entities/system-config.entity';
 | 
				
			||||||
import { IAccessRepository } from 'src/interfaces/access.interface';
 | 
					import { IAccessRepository } from 'src/interfaces/access.interface';
 | 
				
			||||||
import { IAssetRepositoryV1 } from 'src/interfaces/asset-v1.interface';
 | 
					import { IAssetRepositoryV1 } from 'src/interfaces/asset-v1.interface';
 | 
				
			||||||
import { IAssetRepository } from 'src/interfaces/asset.interface';
 | 
					import { IAssetRepository } from 'src/interfaces/asset.interface';
 | 
				
			||||||
@ -244,15 +244,15 @@ export class AssetServiceV1 {
 | 
				
			|||||||
    };
 | 
					    };
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private getThumbnailPath(asset: AssetEntity, format: GetAssetThumbnailFormatEnum) {
 | 
					  private getThumbnailPath(asset: AssetEntity, format: ImageFormat) {
 | 
				
			||||||
    switch (format) {
 | 
					    switch (format) {
 | 
				
			||||||
      case GetAssetThumbnailFormatEnum.WEBP: {
 | 
					      case ImageFormat.WEBP: {
 | 
				
			||||||
        if (asset.thumbnailPath) {
 | 
					        if (asset.thumbnailPath) {
 | 
				
			||||||
          return asset.thumbnailPath;
 | 
					          return asset.thumbnailPath;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        this.logger.warn(`WebP thumbnail requested but not found for asset ${asset.id}, falling back to JPEG`);
 | 
					        this.logger.warn(`WebP thumbnail requested but not found for asset ${asset.id}, falling back to JPEG`);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      case GetAssetThumbnailFormatEnum.JPEG: {
 | 
					      case ImageFormat.JPEG: {
 | 
				
			||||||
        if (!asset.previewPath) {
 | 
					        if (!asset.previewPath) {
 | 
				
			||||||
          throw new NotFoundException(`No thumbnail found for asset ${asset.id}`);
 | 
					          throw new NotFoundException(`No thumbnail found for asset ${asset.id}`);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user