From abdf931a008d1fc8598c9c8a992e7b7adcef74e9 Mon Sep 17 00:00:00 2001 From: Innei Date: Tue, 30 Jan 2024 18:30:28 +0800 Subject: [PATCH] fix:post can custom `created` fixes #1410 Signed-off-by: Innei --- apps/core/src/modules/post/post.controller.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/core/src/modules/post/post.controller.ts b/apps/core/src/modules/post/post.controller.ts index d18422d9..49ad3751 100644 --- a/apps/core/src/modules/post/post.controller.ts +++ b/apps/core/src/modules/post/post.controller.ts @@ -22,6 +22,7 @@ import { CountingService } from '~/processors/helper/helper.counting.service' import { MongoIdDto } from '~/shared/dto/id.dto' import { PagerDto } from '~/shared/dto/pager.dto' import { addYearCondition } from '~/transformers/db-query.transformer' +import { getLessThanNow } from '~/utils' import { CategoryAndSlugDto } from './post.dto' import { PartialPostModel, PostModel } from './post.model' @@ -197,9 +198,10 @@ export class PostController { @Auth() @HTTPDecorators.Idempotence() async create(@Body() body: PostModel) { + body.created = getLessThanNow(body.created) return await this.postService.create({ - ...body, created: new Date(), + ...body, modified: null, slug: body.slug, related: body.relatedId as any,