From 943f10149606363b88c4ca17c3e2f78c9ec45d32 Mon Sep 17 00:00:00 2001 From: Andrei Piankouski Date: Fri, 26 Apr 2024 10:08:26 +0300 Subject: [PATCH] EPMRPP-90118 || Improve Email configuration to take into account possible deployment under path --- .../com/epam/ta/reportportal/util/email/EmailService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/epam/ta/reportportal/util/email/EmailService.java b/src/main/java/com/epam/ta/reportportal/util/email/EmailService.java index 57368d34b9..2087d66864 100644 --- a/src/main/java/com/epam/ta/reportportal/util/email/EmailService.java +++ b/src/main/java/com/epam/ta/reportportal/util/email/EmailService.java @@ -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; @@ -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); } @@ -209,7 +213,8 @@ String mergeFinishLaunchText(String url, Launch launch, Set pr private String getUrl(String baseUrl) { return ofNullable(rpHost).map(rh -> { - final UriComponents rpHostUri = UriComponentsBuilder.fromUriString(rh).build(); + String RPUrl = rpHost + path.replace("/api", ""); + 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);