fix(conversations): exclude DELETED conversations from evolution queries and user operations

- findForEvolution() now excludes DELETED conversations (should not learn from deleted data)
- getConversation() rejects DELETED conversations for user-facing operations (sendMessage, getMessages, etc.)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-06 20:55:04 -08:00
parent d083008001
commit 8d8df53e56
2 changed files with 3 additions and 2 deletions

View File

@ -60,7 +60,8 @@ export class ConversationPostgresRepository
hoursBack?: number;
minMessageCount?: number;
}): Promise<ConversationEntity[]> {
const queryBuilder = this.createTenantQueryBuilder('conversation');
const queryBuilder = this.createTenantQueryBuilder('conversation')
.andWhere('conversation.status != :deletedStatus', { deletedStatus: 'DELETED' });
if (options.status) {
queryBuilder.andWhere('conversation.status = :status', { status: options.status });

View File

@ -87,7 +87,7 @@ export class ConversationService {
): Promise<ConversationEntity> {
const conversation = await this.conversationRepo.findById(conversationId);
if (!conversation || conversation.userId !== userId) {
if (!conversation || conversation.userId !== userId || conversation.isDeleted()) {
throw new NotFoundException('Conversation not found');
}