Skip to content
Snippets Groups Projects
Commit b651be99 authored by Samuli Virtapohja's avatar Samuli Virtapohja
Browse files

finishing audit

parent e1c3c626
No related branches found
No related tags found
2 merge requests!59Development to master,!58Development to testing
......@@ -7,7 +7,7 @@ import { AppController } from './app.controller';
import { AppService } from './app.service';
import { RolesGuard } from './shared/roles.guard';
import { LoggingInterceptor } from './shared/logging.interceptor';
//import { LoggingInterceptor } from './shared/logging.interceptor';
import { StatesGuard } from './shared/states.guard';
import { HttpErrorFilter } from './shared/http-error.filter';
......@@ -58,10 +58,7 @@ import { ReplayModule } from './replay/replay.module';
provide: APP_FILTER,
useClass: HttpErrorFilter,
},
{
provide: APP_INTERCEPTOR,
useClass: LoggingInterceptor,
},
{
provide: APP_GUARD,
useClass: RolesGuard,
......
......@@ -152,6 +152,10 @@ export class FactionService {
relations: ['person', 'group'],
});
players.sort(function(a, b) {
return a.person.name.localeCompare(b.person.name);
});
let groups = await this.game_GroupRepository.find({
where: { faction: factionId },
relations: ['leader', 'leader.person'],
......
import { Injectable, NestInterceptor, ExecutionContext, CallHandler, Logger } from '@nestjs/common';
import {
Injectable,
NestInterceptor,
ExecutionContext,
CallHandler,
Logger,
} from '@nestjs/common';
import { Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
/*
@Injectable()
export class LoggingInterceptor implements NestInterceptor {
intercept(
......@@ -19,4 +25,4 @@ export class LoggingInterceptor implements NestInterceptor {
))
)
}
}
\ No newline at end of file
}*/
......@@ -42,7 +42,7 @@ export class TaskController {
@Roles('admin')
@UsePipes(new ValidationPipe())
async deleteTask(@Param('id') id: string, @Body() data: DeleteTaskDTO) {
return this.taskService.deleteTask(data);
return this.taskService.deleteTask(data, id);
}
// lists all the tasks for the game if the user has game_person entry
......
......@@ -32,7 +32,7 @@ export class TaskService {
await this.taskRepository.insert(createdTask);
// notify subscribers about a new task
// if faction was set it notifies only faction members, else everyone
await this.triggerTasks(task);
this.triggerTasks(task, task.taskGame);
return {
message: 'Task added',
};
......@@ -56,24 +56,17 @@ export class TaskService {
task.taskWinner = data.taskWinner;
task.taskIsActive = false;
await this.taskRepository.save(task);
await this.triggerTasks(task);
this.triggerTasks(task, data.taskGame);
return {
message: 'Task updated and closed',
};
}
private async triggerTasks(task) {
this.notificationGateway.server.emit(
task.faction != null ? task.faction.toString() : task.taskGame.toString(),
{ type: 'task-update' },
);
}
async deleteTask(data: DeleteTaskDTO) {
async deleteTask(data: DeleteTaskDTO, gameId) {
const task = await this.taskRepository.findOne({ taskId: data.taskId });
if (task) {
await this.taskRepository.delete({ taskId: task.taskId });
await this.triggerTasks(task);
this.triggerTasks(task, gameId);
return {
message: 'Task deleted',
};
......@@ -81,6 +74,13 @@ export class TaskService {
throw new HttpException('Task not found', HttpStatus.BAD_REQUEST);
}
private triggerTasks(task, gameId) {
this.notificationGateway.server.emit(gameId, {
type: 'task-update',
message: task.faction != null ? task.faction.toString() : '',
});
}
// finds all tasks if admin and if non-admin player it finds the playres own
// tasks and general tasks
async fetchTasks(gameperson, taskGame) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment