I give up

This commit is contained in:
2026-01-06 00:55:31 +01:00
parent f5dbd70b2f
commit 1ae3416517
3 changed files with 4 additions and 35 deletions

View File

@@ -29,11 +29,8 @@ public class EmailController {
@PostMapping("/mail/send")
public ResponseEntity<String> send(@RequestBody String payload) {
try {
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> map = mapper.readValue(payload, new TypeReference<Map<String, Object>>() {});
//service.send("laurent0206.cr@gmail.com", "Hello from Board Mate!", map);
service.send("laurent0206.cr@gmail.com", "Hello from Board Mate!", payload);
return new ResponseEntity<>(HttpStatus.OK);
} catch (Exception e) {

View File

@@ -30,9 +30,9 @@ public class SendgridService {
this.senderEmail = email;
}
public void send(String dst, String subject, Map<String, Object> payload) throws ServiceException {
public void send(String dst, String subject, String payload) throws ServiceException {
try {
Content content = new Content("text/plain", formatContent(payload));
Content content = new Content("text/plain",payload);
Mail mail = new Mail(this.senderEmail, subject, new Email(dst), content);
Request request = new Request();
@@ -47,29 +47,4 @@ public class SendgridService {
throw new ServiceException("Failed to send email : " + e.getMessage());
}
}
private String formatContent(Map<String, Object> payload) throws JsonProcessingException {
StringBuilder mailBody = new StringBuilder();
mailBody.append("White: ")
.append(payload.get("white_name"))
.append("\n");
mailBody.append("Black: ")
.append(payload.get("black_name"))
.append("\n");
mailBody.append("Time Control: ")
.append(payload.get("time_control"))
.append(" + ")
.append(payload.get("increment"))
.append("\n");
mailBody.append("Timestamp: ")
.append(payload.get("timestamp"))
.append("\n\n");
return mailBody.toString();
}
}

View File

@@ -22,10 +22,7 @@ public class TwilioService {
public void send(String msg) throws ServiceException {
try {
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNode = mapper.readTree(msg);
String content = jsonNode.get("content").asText();
Message.creator(new PhoneNumber("+32496533833"), this.serviceId, content).create();
Message.creator(new PhoneNumber("+32496533833"), this.serviceId, msg).create();
} catch (Exception e){
throw new ServiceException("Failed to send message :" + e.getMessage());
}