diff --git a/packages/bridge-server/src/upload/upload.service.ts b/packages/bridge-server/src/upload/upload.service.ts index e182233..bc022c6 100644 --- a/packages/bridge-server/src/upload/upload.service.ts +++ b/packages/bridge-server/src/upload/upload.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@nestjs/common'; +import { HttpException, HttpStatus, Injectable, NotAcceptableException } from '@nestjs/common'; import { RacersService } from 'src/racers/racers.service'; import { RaceResultsService } from 'src/race-results/race-results.service'; import { RacesService } from 'src/races/races.service'; @@ -49,15 +49,23 @@ export class UploadService { } if(race.endDate.getTime() < Date.now()) { + throw new NotAcceptableException('RaceClosed', {cause: new Error(), description: 'Race closed for new entries.'}) console.log("Too Late!") return; } if(Date.now() < race.startDate.getTime()) { + throw new NotAcceptableException('RaceNotOpen', {cause: new Error(), description: 'Race not yet open for entries.'}) console.log("Too Soon!") return; } + if(body.fileTime < race.startDate.getTime()) { + throw new NotAcceptableException('EarlyReplay', {cause: new Error(), description: 'Replay generated before the race started.'}) + console.log("Race Too Soon!") + return; + } + let result = await this.raceResultsService.create(race.id, currentRacer.id, replay.bestTime, file.path); console.log(result); diff --git a/packages/bridge-ui/src/app/app.config.ts b/packages/bridge-ui/src/app/app.config.ts index 632dae6..35c1101 100644 --- a/packages/bridge-ui/src/app/app.config.ts +++ b/packages/bridge-ui/src/app/app.config.ts @@ -6,6 +6,7 @@ import { provideAnimations } from '@angular/platform-browser/animations'; import { routes } from './app.routes'; import { AuthInterceptor } from './interceptors/auth.interceptor'; +import { SnackbarInterceptor } from './interceptors/snackbar.interceptor'; export const appConfig: ApplicationConfig = { providers: [ @@ -16,5 +17,6 @@ export const appConfig: ApplicationConfig = { ), importProvidersFrom(MatNativeDateModule), {provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true}, + {provide: HTTP_INTERCEPTORS, useClass: SnackbarInterceptor, multi: true}, ] }; diff --git a/packages/bridge-ui/src/app/components/race-details/race-details.component.html b/packages/bridge-ui/src/app/components/race-details/race-details.component.html index b1b6514..2b6cc9f 100644 --- a/packages/bridge-ui/src/app/components/race-details/race-details.component.html +++ b/packages/bridge-ui/src/app/components/race-details/race-details.component.html @@ -41,7 +41,6 @@

Bronze: {{formatMilliseconds(race.bronzeTime)}}