This commit is contained in:
Bastian Wagner
2026-06-15 10:10:47 +02:00
parent cb938d3dc8
commit c2d2157de8
8 changed files with 100 additions and 14 deletions

View File

@@ -8,7 +8,7 @@ import {
} from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { randomUUID } from 'crypto';
import { Repository } from 'typeorm';
import { IsNull, Repository } from 'typeorm';
import { AuditLogService } from '../audit/audit-log.service';
import {
ListTemplate,
@@ -78,6 +78,7 @@ export class ListsService {
name: this.requireName(createDto.name),
description: this.normalizeOptionalText(createDto.description),
kind: this.normalizeKind(createDto.kind),
deletedAt: null,
items: [],
});
@@ -119,6 +120,7 @@ export class ListsService {
? this.normalizeOptionalText(createDto.description)
: template.description,
kind: template.kind,
deletedAt: null,
items: template.items.map((item) =>
this.listItemsRepository.create({
id: randomUUID(),
@@ -157,7 +159,7 @@ export class ListsService {
async listLists(ownerId: string): Promise<UserList[]> {
const ownedLists = await this.listsRepository.find({
where: { ownerId },
where: { ownerId, deletedAt: IsNull() },
relations: { items: true, owner: true, shares: { user: true } },
order: { name: 'ASC', items: { position: 'ASC' } },
});
@@ -176,12 +178,12 @@ export class ListsService {
const sharedList =
share.list ??
(await this.listsRepository.findOne({
where: { id: share.listId },
where: { id: share.listId, deletedAt: IsNull() },
relations: { items: true, owner: true, shares: { user: true } },
order: { items: { position: 'ASC' } },
}));
if (sharedList) {
if (sharedList && !sharedList.deletedAt) {
await this.hydrateListAccessRelations(sharedList);
listsById.set(sharedList.id, sharedList);
}
@@ -245,7 +247,8 @@ export class ListsService {
kind: list.kind,
itemCount: list.items.length,
};
await this.listsRepository.remove(list);
list.deletedAt = new Date();
await this.listsRepository.save(list);
await this.auditLogService?.record({
actorUserId: ownerId,
@@ -503,7 +506,7 @@ export class ListsService {
listId: string,
): Promise<UserListEntity> {
const list = await this.listsRepository.findOne({
where: { id: listId },
where: { id: listId, deletedAt: IsNull() },
relations: { items: true, owner: true, shares: { user: true } },
order: { items: { position: 'ASC' } },
});
@@ -693,7 +696,7 @@ export class ListsService {
}
const list = await this.listsRepository.findOne({
where: { id: listId },
where: { id: listId, deletedAt: IsNull() },
relations: { items: true, owner: true, shares: { user: true } },
order: { items: { position: 'ASC' } },
});