-
Notifications
You must be signed in to change notification settings - Fork 2
[NEW] make the contact mail addresses a environement variable #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
maxones25
wants to merge
11
commits into
dev
Choose a base branch
from
feature/make_contact_mail_address_a_parameter_2
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
94ca0f8
Add Support Mail Address Parameter
maxones25 7f092c0
Add class MailAddress
maxones25 c46f3fa
Add attribute supportMailAddress to view
maxones25 42a8621
Fix Generic Runtime-Error
maxones25 06ba336
Change HTML Mail Attributes to Variables
maxones25 84a1d29
Change HTML Mail Attributes to Variables
maxones25 fbbdf96
Add Attribute supportMailAddress to view
maxones25 878e83f
Add Attribute supportMailAddress to view
maxones25 f854ce9
Change HTML Mail Attributes to Variables
maxones25 956caaa
Use Regex Pattern
maxones25 efeae3b
Return invalid email and log error instead of throw Exception
maxones25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/main/java/de/hs_mannheim/informatik/ct/util/MailAddress.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package de.hs_mannheim.informatik.ct.util; | ||
|
|
||
| import de.hs_mannheim.informatik.ct.persistence.InvalidEmailException; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import lombok.val; | ||
| import lombok.var; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.regex.Matcher; | ||
| import java.util.regex.Pattern; | ||
|
|
||
| @AllArgsConstructor @Getter | ||
| @Slf4j | ||
| public class MailAddress { | ||
| private String mailAddress; | ||
| private String name; | ||
| private String domain; | ||
| private String tld; | ||
|
|
||
| private static final String EMAIL_REGEX = "(.*)@(.*)\\.(.*)$"; | ||
| private static final String DEFAULT_INVALID_MAIL = "invalid-email@invalid.org"; | ||
|
|
||
| public static MailAddress parse(String mailAddress) { | ||
| val match = splitMailAddress(mailAddress); | ||
| val name = match.group(1); | ||
| val domain = match.group(2); | ||
| val tld = match.group(3); | ||
| return new MailAddress(mailAddress, name, domain, tld); | ||
| } | ||
|
|
||
| private static Matcher splitMailAddress(String mailAddress){ | ||
| Matcher match = Pattern.compile(EMAIL_REGEX).matcher(mailAddress); | ||
| if(!match.matches()) { | ||
| match = Pattern.compile(EMAIL_REGEX).matcher(DEFAULT_INVALID_MAIL); | ||
| log.error("support mail address '"+mailAddress+"' is invalid"); | ||
| } | ||
| return match; | ||
| } | ||
|
|
||
| private static List<String> split(String data, String delimiter){ | ||
| return Arrays.asList(data.split(delimiter)); | ||
| } | ||
|
|
||
| private static String joinWithoutLast(List<String> data, String glue){ | ||
| String domain = data.get(0); | ||
| for(int i=1;i < data.size() - 1;i++){ | ||
| domain += glue + data.get(i); | ||
| } | ||
| return domain; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.