Skip to content

Commit c05d5b8

Browse files
committed
fix(shotgun): 409 Conflict on already validated team
1 parent c67a7c1 commit c05d5b8

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

backend/src/controllers/event.controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Request, Response } from "express";
2-
import { Accepted, Error, Ok, Teapot, Unauthorized } from "../utils/responses";
2+
import { Accepted, Conflict, Error, Ok, Teapot, Unauthorized } from "../utils/responses";
33
import * as event_service from "../services/event.service";
44
import * as team_service from "../services/team.service";
55
import { Event } from "../schemas/Basic/event.schema";
@@ -129,7 +129,7 @@ export const shotgunAttempt = async (req: Request, res: Response) => {
129129
const alreadyShotgun = await event_service.alreadyShotgun(userTeam)
130130

131131
if (alreadyShotgun) {
132-
Accepted(res, { msg: "Votre équipe est déjà dans le shotgun." });
132+
Conflict(res, { msg: "Votre équipe est déjà dans le shotgun." });
133133
return;
134134
}
135135

backend/src/utils/responses.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ export const Accepted = (res: Response, details: { data?: any, msg?: string }) =
2424
};
2525

2626
export const Unauthorized = (res: Response, details: { data?: any, msg?: string }) => {
27-
const msg = details.msg || 'Ok';
28-
res.status(Code.UNAUTHORIZED).json(new HttpResponse(Code.OK, msg, details.data));
27+
const msg = details.msg || 'Unauthorized';
28+
res.status(Code.UNAUTHORIZED).json(new HttpResponse(Code.UNAUTHORIZED, msg, details.data));
29+
};
30+
31+
export const Conflict = (res: Response, details: { data?: any, msg?: string }) => {
32+
const msg = details.msg || "Conflict";
33+
res.status(Code.CONFLICT).json(new HttpResponse(Code.CONFLICT, msg, details.data));
2934
};
3035

3136
export const Teapot = (res: Response, details: { data?: any, msg?: string }) => {
@@ -40,6 +45,7 @@ export enum Code {
4045
BAD_REQUEST = 400,
4146
UNAUTHORIZED = 401,
4247
CREATED = 201,
48+
CONFLICT = 409,
4349
IM_A_TEAPOT = 418,
4450
ISE = 500
4551
}
@@ -69,7 +75,9 @@ export class HttpResponse {
6975
case Code.ISE:
7076
return 'INTERNAL_SERVER_ERROR';
7177
case Code.UNAUTHORIZED:
72-
return 'INTERNAL_SERVER_ERROR';
78+
return 'UNAUTHORIZED';
79+
case Code.CONFLICT:
80+
return 'CONFLICT';
7381
case Code.IM_A_TEAPOT:
7482
return 'IM_A_TEAPOT';
7583
}

0 commit comments

Comments
 (0)