Logging und sowas

This commit is contained in:
Bastian Wagner
2026-02-20 10:28:48 +01:00
parent 29bfffc505
commit 4e051a1f40
14 changed files with 87 additions and 22 deletions

View File

@@ -6,6 +6,7 @@ import { User } from 'src/model/entitites';
import { IUser } from 'src/model/interface';
import { MailService } from '../mail/mail.service';
import { ConfigService } from '@nestjs/config';
import { ActivityHelperService } from 'src/shared/service/activity.logger.service';
@Injectable()
export class SystemService {
@@ -14,7 +15,8 @@ export class SystemService {
private userRepo: UserRepository,
private systemActivityRepo: ActivityRepository,
private mailService: MailService,
private readonly configService: ConfigService
private readonly configService: ConfigService,
private readonly activityService: ActivityHelperService
) {}
get isDevelopMode(): boolean {
@@ -59,12 +61,21 @@ export class SystemService {
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
update(id: string, updateSystemDto: UpdateSystemDto) {
throw new HttpException(
`This action updates a #${id} system but is not implemented`,
HttpStatus.NOT_IMPLEMENTED,
);
return `This action updates a #${id} system`;
async update(user: User, updateSystemDto: UpdateSystemDto) {
if (!user || !user.id || !updateSystemDto.id) { throw new HttpException('forbidden', HttpStatus.FORBIDDEN); }
console.log(updateSystemDto);
const system = await this.systemRepo.findOne({ where: { id: updateSystemDto.id, managers: { id: user.id } }, withDeleted: true });
if (!system) { throw new HttpException('forbidden', HttpStatus.FORBIDDEN); }
if (system.name !== updateSystemDto.name) {
await this.activityService.logSystemRenamed({ system, newName: updateSystemDto.name, user })
system.name = updateSystemDto.name;
}
return true;
}
async remove(id: string) {