diff --git a/src/app.module.ts b/src/app.module.ts index 571d9240e67c2f34fc52785f793f43b86bc78730..d3461d27ad0dae5ac43b55c12035af684268717a 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -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, diff --git a/src/faction/faction.service.ts b/src/faction/faction.service.ts index a3ea83ebefb7b34e2bb83fa714a1b0b7817acb8a..ba9370b0a98bed5febf6f05ffeeed6866e909c60 100644 --- a/src/faction/faction.service.ts +++ b/src/faction/faction.service.ts @@ -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'], diff --git a/src/shared/logging.interceptor.ts b/src/shared/logging.interceptor.ts index 55083faabd0a781ace687fc2cb9c2977f0befaa9..c29717474c87516cc3e1492bc24a5f13f848c89a 100644 --- a/src/shared/logging.interceptor.ts +++ b/src/shared/logging.interceptor.ts @@ -1,7 +1,13 @@ -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 +}*/ diff --git a/src/task/task.controller.ts b/src/task/task.controller.ts index 14bbb215de47785a8bf9c284c1b0ef969b1ae84f..ba9f6cc9e9be2e6f8408c337ed270d0a587d2ba9 100644 --- a/src/task/task.controller.ts +++ b/src/task/task.controller.ts @@ -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 diff --git a/src/task/task.service.ts b/src/task/task.service.ts index d09eb1cda37435a1392563365bd25a23735ba6ea..0461d310de44f882ccdf18c4b2ba29f01cb5d8a7 100644 --- a/src/task/task.service.ts +++ b/src/task/task.service.ts @@ -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) {