From 152274e3cd9ba0baad30af58a0db1a2ab0b01d7a Mon Sep 17 00:00:00 2001 From: Peter Havekes Date: Thu, 21 Aug 2025 14:06:06 +0200 Subject: [PATCH 1/2] Log the data that's sent to the sms provider --- .../src/main/java/myconext/sms/SMSServiceImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/myconext-server/src/main/java/myconext/sms/SMSServiceImpl.java b/myconext-server/src/main/java/myconext/sms/SMSServiceImpl.java index 678ead54f..b58575af8 100644 --- a/myconext-server/src/main/java/myconext/sms/SMSServiceImpl.java +++ b/myconext-server/src/main/java/myconext/sms/SMSServiceImpl.java @@ -1,7 +1,10 @@ package myconext.sms; import lombok.SneakyThrows; +import myconext.tiqr.TiqrController; import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.core.io.ClassPathResource; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -25,6 +28,8 @@ public class SMSServiceImpl implements SMSService { private final String templateEn; private final RestTemplate restTemplate = new RestTemplate(); private final MultiValueMap headers = new HttpHeaders(); + private static final Log LOG = LogFactory.getLog(SMSServiceImpl.class); + @SneakyThrows public SMSServiceImpl(String url, String bearer, String route) { @@ -54,6 +59,7 @@ public String send(String mobile, String code, Locale locale) { ); RequestEntity requestEntity = new RequestEntity(body, headers, HttpMethod.POST, URI.create(url)); + LOG.info(String.format("SMS url : %s, route : %s body: %s", url, route, requestEntity.getBody())); restTemplate.exchange(requestEntity, Void.class); return format; } From dea92f1a4d825309db473f2d9d1cc92d71c430a2 Mon Sep 17 00:00:00 2001 From: Okke Harsta Date: Thu, 21 Aug 2025 14:39:16 +0200 Subject: [PATCH 2/2] Reuse body variable --- .../src/main/java/myconext/sms/SMSServiceImpl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/myconext-server/src/main/java/myconext/sms/SMSServiceImpl.java b/myconext-server/src/main/java/myconext/sms/SMSServiceImpl.java index b58575af8..80a888983 100644 --- a/myconext-server/src/main/java/myconext/sms/SMSServiceImpl.java +++ b/myconext-server/src/main/java/myconext/sms/SMSServiceImpl.java @@ -22,13 +22,14 @@ @SuppressWarnings("unchecked") public class SMSServiceImpl implements SMSService { + private static final Log LOG = LogFactory.getLog(SMSServiceImpl.class); + private final String url; public final String route; private final String templateNl; private final String templateEn; private final RestTemplate restTemplate = new RestTemplate(); private final MultiValueMap headers = new HttpHeaders(); - private static final Log LOG = LogFactory.getLog(SMSServiceImpl.class); @SneakyThrows @@ -58,8 +59,11 @@ public String send(String mobile, String code, Locale locale) { "recipients", List.of(mobile) ); - RequestEntity requestEntity = new RequestEntity(body, headers, HttpMethod.POST, URI.create(url)); - LOG.info(String.format("SMS url : %s, route : %s body: %s", url, route, requestEntity.getBody())); + RequestEntity requestEntity = new RequestEntity<>(body, headers, HttpMethod.POST, URI.create(url)); + LOG.info(String.format("Sending SMS with url : %s, route : %s body: %s", + url, + route, + body)); restTemplate.exchange(requestEntity, Void.class); return format; }