Browse Source

get album response

Alex Tran 1 year ago
parent
commit
51ffac5d15

+ 27 - 1
server/immich-openapi-specs.json

@@ -4858,6 +4858,12 @@
           "ownerId": {
             "type": "string"
           },
+          "rules": {
+            "items": {
+              "$ref": "#/components/schemas/RuleResponseDto"
+            },
+            "type": "array"
+          },
           "shared": {
             "type": "boolean"
           },
@@ -4884,7 +4890,8 @@
           "shared",
           "sharedUsers",
           "assets",
-          "owner"
+          "owner",
+          "rules"
         ],
         "type": "object"
       },
@@ -6210,6 +6217,25 @@
         ],
         "type": "string"
       },
+      "RuleResponseDto": {
+        "properties": {
+          "key": {
+            "$ref": "#/components/schemas/RuleKey"
+          },
+          "ownerId": {
+            "type": "string"
+          },
+          "value": {
+            "type": "string"
+          }
+        },
+        "required": [
+          "key",
+          "value",
+          "ownerId"
+        ],
+        "type": "object"
+      },
       "SearchAlbumResponseDto": {
         "properties": {
           "count": {

+ 3 - 0
server/src/domain/album/album-response.dto.ts

@@ -2,6 +2,7 @@ import { AlbumEntity } from '@app/infra/entities';
 import { ApiProperty } from '@nestjs/swagger';
 import { AssetResponseDto, mapAsset } from '../asset';
 import { mapUser, UserResponseDto } from '../user';
+import { RuleResponseDto } from './dto/rule.dto';
 
 export class AlbumResponseDto {
   id!: string;
@@ -18,6 +19,7 @@ export class AlbumResponseDto {
   @ApiProperty({ type: 'integer' })
   assetCount!: number;
   lastModifiedAssetTimestamp?: Date;
+  rules!: RuleResponseDto[];
 }
 
 const _map = (entity: AlbumEntity, withAssets: boolean): AlbumResponseDto => {
@@ -41,6 +43,7 @@ const _map = (entity: AlbumEntity, withAssets: boolean): AlbumResponseDto => {
     shared: sharedUsers.length > 0 || entity.sharedLinks?.length > 0,
     assets: withAssets ? entity.assets?.map((asset) => mapAsset(asset)) || [] : [],
     assetCount: entity.assets?.length || 0,
+    rules: entity.rules?.map((rule) => ({ key: rule.key, value: rule.value, ownerId: rule.ownerId })) || [],
   };
 };
 

+ 7 - 0
server/src/domain/album/dto/rule.dto.ts

@@ -10,3 +10,10 @@ export class CreateRuleDto {
   @IsNotEmpty()
   value!: string;
 }
+
+export class RuleResponseDto {
+  @ApiProperty({ enumName: 'RuleKey', enum: RuleKey })
+  key!: RuleKey;
+  value!: string;
+  ownerId!: string;
+}