Browse Source

block unblock

master
Pheuw1 2 years ago
parent
commit
bb2bf1d0c7
  1. 20
      back/volume/src/users/users.controller.ts

20
back/volume/src/users/users.controller.ts

@ -37,6 +37,24 @@ export class UsersController {
private readonly usersService: UsersService, private readonly usersService: UsersService,
) {} ) {}
@UseGuards(AuthenticatedGuard)
@Post("block/:id")
async blockUser(@Profile42() profile :Profile, @Param('id') id:number) {
const user = await this.usersService.findUser(id) as User
user.blocked.push((await this.usersService.findUser(+profile.id)) as User)
this.usersService.save(user);
}
@UseGuards(AuthenticatedGuard)
@Post("unblock/:id")
async unblockUser(@Profile42() profile :Profile, @Param('id') id:number) {
const user = await this.usersService.findUser(id) as User
user.blocked = user.blocked.filter((usr: User) => {
return usr.id !== id
})
this.usersService.save(user);
}
@Get('all') @Get('all')
async getAllUsers (): Promise<User[]> { async getAllUsers (): Promise<User[]> {
return await this.usersService.findUsers() return await this.usersService.findUsers()
@ -76,7 +94,7 @@ export class UsersController {
fileFilter: (request: Request, file: Express.Multer.File, callback) => { fileFilter: (request: Request, file: Express.Multer.File, callback) => {
if (!file.mimetype.includes('image')) { if (!file.mimetype.includes('image')) {
callback(null, false) callback(null, false)
return return
} }
callback(null, true) callback(null, true)
} }

Loading…
Cancel
Save