From ea46dd664cd3ea193dfd754c5e6a6199fa84b79e Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Sun, 17 Mar 2024 16:02:30 +0100 Subject: [PATCH] added a todo to send an email for every state changement of request --- .../Clyde/EndPoints/InscriptionController.java | 16 ---------------- .../Clyde/Services/InscriptionService.java | 10 ++++++++++ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java index 814c185..1c273ba 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java @@ -58,22 +58,6 @@ public class InscriptionController { return new ResponseEntity<>(requestWithoutPassword(foundInscriptionRequest), HttpStatus.OK); } - /** - @GetMapping("request/user") - public ResponseEntity getUserInscriptionRequest(@RequestHeader("Authorization") String token){ - //todo return l'inscriptionRequest ACTUELLE du user (check si le poster est bien le même que id target ou secretariat) - - if (authServ.IsNotIn(new Role[]{Role.Student,Role.Admin},token)) - return new UnauthorizedResponse<>(null); - - User poster = authServ.getUserFromToken(token); - - inscriptionServ.getById() - - - return null; - } **/ - @PatchMapping("/request/register/{id}") public ResponseEntity changeRequestState(@PathVariable long id, @RequestHeader("Authorization") String token, diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java index 31b18a6..4712f8f 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java @@ -32,6 +32,16 @@ public class InscriptionService { if (inscriptionRequest == null) return false; + // if th state is the same we don't send an email + if (requestState == inscriptionRequest.getState()) + return false; + + /** todo send an email to tell the poster of the inscriptionRequest (inscriptionRequest.getEmail()) + * to notify them that the state of their request changed + * FooEmailFormat toSend = (String.format("Your request state changed from %s to %s"), + * inscriptionRequest.getState(), requestState) + * FooEmailSender.send(toSend, inscriptionRequest.getEmail()) + */ inscriptionRequest.setState(requestState); save(inscriptionRequest); return true;