Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion mobile/openapi/lib/model/memory_create_dto.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions open-api/immich-openapi-specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -18681,6 +18681,22 @@
"data": {
"$ref": "#/components/schemas/OnThisDayDto"
},
"hideAt": {
"description": "Date when memory should be hidden",
"format": "date-time",
"type": "string",
"x-immich-history": [
{
"version": "v2.6.0",
"state": "Added"
},
{
"version": "v2.6.0",
"state": "Stable"
}
],
"x-immich-state": "Stable"
},
"isSaved": {
"description": "Is memory saved",
"type": "boolean"
Expand All @@ -18695,6 +18711,22 @@
"format": "date-time",
"type": "string"
},
"showAt": {
"description": "Date when memory should be shown",
"format": "date-time",
"type": "string",
"x-immich-history": [
{
"version": "v2.6.0",
"state": "Added"
},
{
"version": "v2.6.0",
"state": "Stable"
}
],
"x-immich-state": "Stable"
},
"type": {
"allOf": [
{
Expand Down
4 changes: 4 additions & 0 deletions open-api/typescript-sdk/src/fetch-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1406,12 +1406,16 @@ export type MemoryCreateDto = {
/** Asset IDs to associate with memory */
assetIds?: string[];
data: OnThisDayDto;
/** Date when memory should be hidden */
hideAt?: string;
/** Is memory saved */
isSaved?: boolean;
/** Memory date */
memoryAt: string;
/** Date when memory was seen */
seenAt?: string;
/** Date when memory should be shown */
showAt?: string;
/** Memory type */
"type": MemoryType;
};
Expand Down
14 changes: 14 additions & 0 deletions server/src/controllers/memory.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ describe(MemoryController.name, () => {
errorDto.badRequest(['data.year must be a positive number', 'data.year must be an integer number']),
);
});

it('should accept showAt and hideAt', async () => {
const { status } = await request(ctx.getHttpServer())
.post('/memories')
.send({
type: 'on_this_day',
data: { year: 2020 },
memoryAt: new Date(2021).toISOString(),
showAt: new Date(2022).toISOString(),
hideAt: new Date(2023).toISOString(),
});

expect(status).toBe(201);
});
});

describe('GET /memories/statistics', () => {
Expand Down
15 changes: 15 additions & 0 deletions server/src/dtos/memory.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsInt, IsObject, IsPositive, ValidateNested } from 'class-validator';
import { Memory } from 'src/database';
import { HistoryBuilder } from 'src/decorators';
import { AssetResponseDto, mapAsset } from 'src/dtos/asset-response.dto';
import { AuthDto } from 'src/dtos/auth.dto';
import { AssetOrderWithRandom, MemoryType } from 'src/enum';
Expand Down Expand Up @@ -77,6 +78,20 @@ export class MemoryCreateDto extends MemoryBaseDto {
@ValidateDate({ description: 'Memory date' })
memoryAt!: Date;

@ValidateDate({
optional: true,
description: 'Date when memory should be shown',
history: new HistoryBuilder().added('v2.6.0').stable('v2.6.0'),
})
showAt?: Date;

@ValidateDate({
optional: true,
description: 'Date when memory should be hidden',
history: new HistoryBuilder().added('v2.6.0').stable('v2.6.0'),
})
hideAt?: Date;

@ValidateUUID({ optional: true, each: true, description: 'Asset IDs to associate with memory' })
assetIds?: string[];
}
Expand Down
2 changes: 2 additions & 0 deletions server/src/services/memory.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export class MemoryService extends BaseService {
data: dto.data,
isSaved: dto.isSaved,
memoryAt: dto.memoryAt,
showAt: dto.showAt,
hideAt: dto.hideAt,
seenAt: dto.seenAt,
},
allowedAssetIds,
Expand Down
4 changes: 2 additions & 2 deletions server/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export const ValidateHexColor = () => {
};

type DateOptions = OptionalOptions & { optional?: boolean; format?: 'date' | 'date-time' };
export const ValidateDate = (options?: DateOptions & ApiPropertyOptions) => {
export const ValidateDate = (options?: DateOptions & PropertyOptions) => {
const {
optional,
nullable = false,
Expand All @@ -243,7 +243,7 @@ export const ValidateDate = (options?: DateOptions & ApiPropertyOptions) => {
} = options || {};

return applyDecorators(
ApiProperty({ format, ...apiPropertyOptions }),
Property({ format, ...apiPropertyOptions }),
IsDate(),
optional ? Optional({ nullable, emptyToNull }) : IsNotEmpty(),
Transform(({ key, value }) => {
Expand Down
Loading