Skip to content
Snippets Groups Projects

Group fix

Merged Ghost User requested to merge group-fix into Development
9 files
+ 89
58
Compare changes
  • Side-by-side
  • Inline
Files
9
@@ -7,12 +7,19 @@ import {
@@ -7,12 +7,19 @@ import {
Body,
Body,
Get,
Get,
Put,
Put,
 
UseInterceptors,
 
ClassSerializerInterceptor,
} from '@nestjs/common';
} from '@nestjs/common';
import { AuthGuard } from '../shared/auth.guard';
import { AuthGuard } from '../shared/auth.guard';
import { ValidationPipe } from '../shared/validation.pipe';
import { ValidationPipe } from '../shared/validation.pipe';
import { User } from '../user/user.decorator';
import { User } from '../user/user.decorator';
import { GameGroupDTO, PromotePlayerDTO, JoinFactionDTO } from './faction.dto';
import {
 
GameGroupDTO,
 
PromotePlayerDTO,
 
JoinFactionDTO,
 
JoinGameGroupDTO,
 
} from './faction.dto';
import { FactionService } from './faction.service';
import { FactionService } from './faction.service';
import { Roles } from '../shared/roles.decorator';
import { Roles } from '../shared/roles.decorator';
@@ -20,8 +27,9 @@ import { Roles } from '../shared/roles.decorator';
@@ -20,8 +27,9 @@ import { Roles } from '../shared/roles.decorator';
export class FactionController {
export class FactionController {
constructor(private factionservice: FactionService) {}
constructor(private factionservice: FactionService) {}
@Post(':id')
// takes gameId from the url to verify user role
@UseGuards(new AuthGuard())
@Post('create-group/:id')
 
@Roles('soldier')
@UsePipes(new ValidationPipe())
@UsePipes(new ValidationPipe())
async createGroup(
async createGroup(
@User('id') person,
@User('id') person,
@@ -33,17 +41,24 @@ export class FactionController {
@@ -33,17 +41,24 @@ export class FactionController {
} catch (error) {}
} catch (error) {}
}
}
@Get('get-groups')
// id is faction ID
async getGroups() {
@Get('get-groups/:id')
return this.factionservice.showGroups();
async getGroups(@Param('id') id) {
 
return this.factionservice.showGroups(id);
}
}
@Put('groups/:id')
// takes gameId from the url to verify user role
@UseGuards(new AuthGuard())
@Put('join-group/:id')
async joinGroup(@User('id') person, @Param('id') id) {
@Roles('soldier')
return this.factionservice.joinGroup(person, id);
async joinGroup(
 
@User('id') person,
 
@Param('id') id,
 
@Body() data: JoinGameGroupDTO,
 
) {
 
return this.factionservice.joinGroup(person, id, data);
}
}
 
@UseInterceptors(ClassSerializerInterceptor)
@Get('get-faction-members/:id')
@Get('get-faction-members/:id')
async getFactionMembers(@Param('id') factionId) {
async getFactionMembers(@Param('id') factionId) {
return this.factionservice.listFactionMembers(factionId);
return this.factionservice.listFactionMembers(factionId);
Loading