fix: правки

This commit is contained in:
2026-10-10 02:13:35 +03:00
parent 1bef3845bc
commit ff47290919
30 changed files with 902 additions and 183 deletions
+2 -4
View File
@@ -3,15 +3,13 @@ import { ConfigService } from '@nestjs/config';
import { setTimeout as delay } from 'node:timers/promises';
import type { AppConfig } from '../../config/app-config.schema.js';
import { RedisClient } from '../../redis/redis.client.js';
import type { Page } from '../../common/http/page.js';
import { MetricsService } from '../../metrics/metrics.service.js';
const LOCK_RETRY_COUNT = 4;
const LOCK_RETRY_DELAY_MS = 25;
export type CachePage = {
items: unknown[];
next_cursor: string | null;
};
export type CachePage = Page<unknown>;
@Injectable()
export class MessagesCacheService {
+3 -2
View File
@@ -1,7 +1,8 @@
import { IsString, Length } from 'class-validator';
import { IsString } from 'class-validator';
import { CodePointLength } from '../../common/validation/code-point-length.js';
export class CreateMessageDto {
@IsString()
@Length(1, 4000)
@CodePointLength(1, 4000)
text!: string;
}
-2
View File
@@ -1,12 +1,10 @@
import {
BadRequestException,
Injectable,
NotFoundException,
} from '@nestjs/common';
import { randomUUID } from 'node:crypto';
import { DatabaseClient } from '../database/database.client.js';
import type { Cursor } from '../common/http/cursor.js';
import type { User } from '../users/user.js';
import type { Message } from './message.js';
type MessageRow = {
+3 -2
View File
@@ -1,5 +1,6 @@
import { BadRequestException, Injectable } from '@nestjs/common';
import { decodeCursor, encodeCursor } from '../common/http/cursor.js';
import type { Page } from '../common/http/page.js';
import type { User } from '../users/user.js';
import { ChatsService } from '../chats/chats.service.js';
import type { CreateMessageDto } from './dto/create-message.dto.js';
@@ -35,7 +36,7 @@ export class MessagesService {
currentUser: User,
limit: number,
cursorValue?: string,
): Promise<{ items: Message[]; next_cursor: string | null }> {
): Promise<Page<Message>> {
await this.chatsService.getForUser(chatId, currentUser);
const scope = `messages:${chatId}`;
const cursor = cursorValue
@@ -70,6 +71,6 @@ export class MessagesService {
};
},
);
return page as { items: Message[]; next_cursor: string | null };
return page as Page<Message>;
}
}