Skip to content

Commit

Permalink
Better check of recipients
Browse files Browse the repository at this point in the history
  • Loading branch information
euskalhenriko committed Feb 29, 2024
1 parent e2ec9f9 commit 88f2770
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,22 @@ public ResponseEntity<?> sendEmail(@RequestBody KlabEmail email) {
Set<String> recipients = new HashSet<String>();
if (email.to != null && email.to.size() > 0) {
for(String userEmail: email.to) {
if (!userEmail.contains("@")) {
userEmail = userEmail + "@" + emailConfig.defaultDomain();
}
if (Arrays.asList(emailConfig.getAllowedEmailAddresses()).contains(userEmail)) {
recipients.add(userEmail);
}
if (recipients.size() == 0) {
throw new MailAddressNotAllowedException(userEmail);
if (userEmail.length() > 0) {
if (!userEmail.contains("@")) {
userEmail = userEmail + "@" + emailConfig.defaultDomain();
}
if (Arrays.asList(emailConfig.getAllowedEmailAddresses()).contains(userEmail)) {
recipients.add(userEmail);
} else {
throw new MailAddressNotAllowedException(userEmail);
}
}
}
if (recipients.size() == 0) {
recipients.add(emailConfig.defaultRecipient());
}
} else {
recipients.add(emailConfig.defaultRecipient());

}


Expand Down

0 comments on commit 88f2770

Please sign in to comment.