Skip to content

Commit

Permalink
EPMRPP-90118 || Improve Email configuration to take into account poss…
Browse files Browse the repository at this point in the history
…ible deployment under path
  • Loading branch information
APiankouski committed Apr 26, 2024
1 parent ab72f42 commit 943f101
Showing 1 changed file with 6 additions and 1 deletion.
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", "");
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

0 comments on commit 943f101

Please sign in to comment.