Logging und sowas
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user