mirror of
https://github.com/MrSedan/neuro-reply-website.git
synced 2026-01-14 20:49:42 +03:00
deBan => unBan
This commit is contained in:
@@ -19,9 +19,9 @@ export class UserController {
|
|||||||
async banUser(@Param('id') id: string) {
|
async banUser(@Param('id') id: string) {
|
||||||
return await this.userService.banUser(id);
|
return await this.userService.banUser(id);
|
||||||
}
|
}
|
||||||
@Put('deBan/:id')
|
@Put('unBan/:id')
|
||||||
async deBanUser(@Param('id') id: string) {
|
async unBanUser(@Param('id') id: string) {
|
||||||
return await this.userService.deBanUser(id);
|
return await this.userService.unBanUser(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Injectable, Logger } from '@nestjs/common';
|
import { HttpException, HttpStatus, Injectable, Logger } from '@nestjs/common';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { User } from 'libs/database/user.entity';
|
import { User } from 'libs/database/user.entity';
|
||||||
import { Repository } from 'typeorm';
|
import { Repository } from 'typeorm';
|
||||||
@@ -43,22 +43,20 @@ export class UserService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async deBanUser(id: string){
|
async unBanUser(id: string){
|
||||||
try {
|
try {
|
||||||
this.logger.debug(`[user.deBanUser] id: ${JSON.stringify(id)}`);
|
this.logger.debug(`[user.deBanUser] id: ${JSON.stringify(id)}`);
|
||||||
let user = await this.userRepository.findOne({
|
let user = await this.userRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
if(user){
|
if (!user){
|
||||||
user.banned = false;
|
throw new HttpException('No user with this id', HttpStatus.BAD_REQUEST);
|
||||||
await this.userRepository.save(user);
|
|
||||||
return user;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
user = await this.userRepository.save({ id: id, banned: false });
|
user = await this.userRepository.save({ id: id, banned: false });
|
||||||
return user;
|
return user;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.log(`[user.deBanUser] ${JSON.stringify({ error })}`);
|
this.logger.log(`[user.deBanUser] ${JSON.stringify({ error })}`);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user