Skip to content

Commit 14e24e1

Browse files
committed
mark htmlBody nullable and add check
1 parent 20ad6ad commit 14e24e1

4 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/main/java/it/aboutbits/springboot/emailservice/lib/EmailDto.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public record EmailDto(
2626
List<String> recipients,
2727

2828
String textBody,
29+
30+
@Nullable
2931
String htmlBody,
3032

3133
Set<EmailAttachmentDto> attachments,

src/main/java/it/aboutbits/springboot/emailservice/lib/application/EmailParameter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public record Email(
3434
List<String> recipients,
3535

3636
String textBody,
37+
38+
@Nullable
3739
String htmlBody,
3840

3941
@NotBlank

src/main/java/it/aboutbits/springboot/emailservice/lib/application/ManageEmail.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ private void sendMail(
184184
String replyToName,
185185
List<String> recipients,
186186
String subject,
187+
@Nullable
187188
String htmlBody,
188189
String plainTextBody,
189190
Set<EmailAttachment> attachments
@@ -203,7 +204,7 @@ private void sendMail(
203204
}
204205
}
205206

206-
if (!htmlBody.isBlank()) {
207+
if (htmlBody != null && !htmlBody.isBlank()) {
207208
helper.setText(plainTextBody, htmlBody);
208209
} else {
209210
helper.setText(plainTextBody);

src/main/java/it/aboutbits/springboot/emailservice/lib/model/EmailContent.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public record EmailContent(
2525
List<String> recipients,
2626

2727
String textBody,
28+
29+
@Nullable
2830
String htmlBody
2931
) {
3032
}

0 commit comments

Comments
 (0)