[NEW] make the contact mail addresses a environement variable - #282
[NEW] make the contact mail addresses a environement variable#282maxones25 wants to merge 11 commits into
Conversation
MorMundHS-MA
left a comment
There was a problem hiding this comment.
Looks good, the regex change isn't a must-have but the error handling should be improved.
I assume the idea is to allow other schools/organizations use the app more easily. If so we should use proper internationalization to allow customization of the text on the website. https://www.baeldung.com/spring-boot-internationalization
| private String domain; | ||
| private String tld; | ||
|
|
||
| public static MailAddress parse(String mailAddress) throws MailAddressInvalidException { |
There was a problem hiding this comment.
I think its more readable using a regex to split the e-mail.
private static final Pattern email_splitter_regex = Pattern.compile("(.*)@(.*)\\.(.*)$");
public static MailAddress parse(String mailAddress) throws InvalidEmailException {
val match = email_splitter_regex.matcher(mailAddress);
if(!match.matches()) {
throw new InvalidEmailException();
}
val name = match.group(1);
val domain = match.group(2);
val tld = match.group(3);
return new MailAddress(mailAddress, name, domain, tld);
}| } | ||
|
|
||
| @ResponseStatus(code = HttpStatus.NOT_FOUND, reason = "Mail Address invalid") | ||
| public static class MailAddressInvalidException extends RuntimeException { |
There was a problem hiding this comment.
There already is an InvalidEmailException. But it probably should be more explicit about this being a configuration error vs. a user entering an invalid email. Maybe using a default email like invalid-email@invalid.org + logging an error makes more sense.
| import java.util.List; | ||
|
|
||
| @AllArgsConstructor @Getter | ||
| public class MailAddress { |
There was a problem hiding this comment.
Am I getting this right, that this class and the whole parsing is only done to decompose the mail address for the mail obfuscation used in the frontend? Wouldn't it be easier to decompose this manually in the properties file and access the elements from the frontend directly? (like so: https://stackoverflow.com/questions/56102116/access-application-properties-value-in-thymeleaf-template)
There was a problem hiding this comment.
yes, you could also enter the email address already split into the properties. I thought that might be a bit more comfortable in the configuration if the splitting happens automatically.
Related Issue
Proposed Changes
Additional Info
Checklist