Message entities in editing post

This commit is contained in:
2024-02-06 12:42:08 +03:00
parent a42dd9501b
commit 20d0335364
3 changed files with 5 additions and 2 deletions

View File

@@ -12,4 +12,6 @@ export class ICreatePost {
export class IEditPost { export class IEditPost {
@ApiProperty({ description: 'Post text', example: 'Post text' }) readonly text!: string; @ApiProperty({ description: 'Post text', example: 'Post text' }) readonly text!: string;
@ApiProperty({ description: 'Message entities of text', example: '[]' }) readonly message_entities?: string;
} }

View File

@@ -60,8 +60,9 @@ export class PostService {
throw new HttpException('There are only ' + posts.length + ' unsent messages.', HttpStatus.BAD_REQUEST); throw new HttpException('There are only ' + posts.length + ' unsent messages.', HttpStatus.BAD_REQUEST);
} }
const post = posts[Math.abs(+order) - 1]; const post = posts[Math.abs(+order) - 1];
if (post.text !== data.text) { if (post.text !== data.text || post.message_entities !== data.message_entities) {
post.text = data.text; post.text = data.text;
post.message_entities = data.message_entities;
post.edit_timestamp = new Date(); post.edit_timestamp = new Date();
await this.postRepository.save(post); await this.postRepository.save(post);
} }