This commit is contained in:
a.ilin
2026-10-05 22:25:57 +03:00
parent 1bceb8e300
commit 261881b9c6
@@ -7,6 +7,7 @@ import org.springframework.http.client.ClientHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestClient;
import lombok.Builder;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.PropertyNamingStrategies;
import tools.jackson.databind.annotation.JsonNaming;
@@ -40,12 +41,14 @@ public class UnisenderClient {
}
public void sendEmail(String to, String subject, String plaintext) {
SendRequest request = new SendRequest(new SendRequest.Message(
List.of(new SendRequest.Recipient(to)),
new SendRequest.Body(plaintext),
subject,
properties.fromEmail(),
properties.fromName()));
SendRequest request = new SendRequest(SendRequest.Message.builder()
.recipients(List.of(new SendRequest.Recipient(to)))
.body(new SendRequest.Body(plaintext))
.subject(subject)
.fromEmail(properties.fromEmail())
.fromName(properties.fromName())
.bypassGlobal(1)
.build());
SendResponse response;
try {
response = restClient.post()
@@ -84,8 +87,9 @@ public class UnisenderClient {
record SendRequest(Message message) {
@Builder
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
record Message(List<Recipient> recipients, Body body, String subject, String fromEmail, String fromName) {
record Message(List<Recipient> recipients, Body body, String subject, String fromEmail, String fromName, int bypassGlobal) {
}
record Recipient(String email) {