Skip to content
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

EPMRPP-90118 || Improve Email configuration to take into account possible deployment under path #1976

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import javax.mail.internet.InternetAddress;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.FileUrlResource;
import org.springframework.core.io.Resource;
import org.springframework.mail.javamail.JavaMailSender;
Expand Down Expand Up @@ -83,6 +84,9 @@ public class EmailService extends JavaMailSenderImpl {
private String from;
private String rpHost;

@Value("${server.servlet.context.path:}")
private String path;

public EmailService(Properties javaMailProperties) {
super.setJavaMailProperties(javaMailProperties);
}
Expand Down Expand Up @@ -209,7 +213,8 @@ String mergeFinishLaunchText(String url, Launch launch, Set<ProjectIssueType> pr

private String getUrl(String baseUrl) {
return ofNullable(rpHost).map(rh -> {
final UriComponents rpHostUri = UriComponentsBuilder.fromUriString(rh).build();
String RPUrl = rpHost + path.replace("/api", "");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.naming.AbbreviationAsWordInNameCheck> reported by reviewdog 🐶
Abbreviation in name 'RPUrl' must contain no more than '1' consecutive capital letters.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck> reported by reviewdog 🐶
Local variable name 'RPUrl' must match pattern '^a-z?$'.

final UriComponents rpHostUri = UriComponentsBuilder.fromUriString(RPUrl).build();
return UriComponentsBuilder.fromUriString(baseUrl).scheme(rpHostUri.getScheme())
.host(rpHostUri.getHost()).port(rpHostUri.getPort()).build().toUri().toASCIIString();
}).orElse(baseUrl);
Expand Down
Loading