Compare commits

...

6 Commits

Author SHA1 Message Date
Niclas Thobaben 18e99bce54 v1.0.1
nclazz/nclazz-mail-relay/pipeline/head There was a failure building this commit Details
2022-02-25 16:01:44 +01:00
Niclas Thobaben 9efd92f844 Merge pull request 'issue/19+20 Closes #19 #20' (#21) from issue/19+20 into master
nclazz/nclazz-mail-relay/pipeline/head Something is wrong with the build of this commit Details
Reviewed-on: #21
2022-02-25 15:58:31 +01:00
Niclas Thobaben dd23dfca8e Enable usage of relative urls by prepending referer on relative paths
nclazz/nclazz-mail-relay/pipeline/head This commit looks good Details
nclazz/nclazz-mail-relay/pipeline/pr-master This commit looks good Details
2022-02-25 15:55:38 +01:00
Niclas Thobaben 74f4e9b2d8 Added 'Send via..' footer in mail #20 2022-02-25 15:51:43 +01:00
Niclas Thobaben 1d9f6d4470 [maven-release-plugin] prepare release v1.0.0
nclazz/nclazz-mail-relay/pipeline/head This commit looks good Details
2022-02-15 18:55:03 +01:00
Niclas Thobaben 461a70b91f Set Docker Image Version to 1.0.0 2022-02-15 18:45:25 +01:00
4 changed files with 27 additions and 12 deletions

3
Jenkinsfile vendored
View File

@ -11,7 +11,7 @@ pipeline {
DOCKER_GROUP = 'nclazz-service'
DOCKER_IMAGE = 'mail-relay'
DOCKER_TAG = "${ BRANCH_NAME == "master" ? "latest" : "develop" }"
DOCKER_VERSION = "0.0.1-SNAPSHOT"
DOCKER_VERSION = "1.0.0"
DEPLOY_ENV = "${ BRANCH_NAME == "master" ? "production" : "staging" }"
}
@ -91,7 +91,6 @@ pipeline {
allOf {
anyOf {
branch 'master'
branch 'develop'
expression { return params.RUN_DEPLOYMENT }
}
}

13
pom.xml
View File

@ -1,24 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.3</version>
<relativePath/> <!-- lookup parent from repository -->
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>de.nclazz.service</groupId>
<artifactId>mail-relay</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.0.1</version>
<name>mail-relay</name>
<description>Service for relaying mails from other services or static sites</description>
<scm>
<connection>scm:git:https://git.l--n.de/nclazz/nclazz-mail-relay</connection>
</scm>
<tag>v1.0.0</tag>
</scm>
<properties>
<java.version>11</java.version>
@ -309,7 +308,7 @@
<requireJavaVersion>
<version>11</version>
</requireJavaVersion>
<banDuplicatePomDependencyVersions/>
<banDuplicatePomDependencyVersions />
</rules>
</configuration>
<executions>

View File

@ -34,9 +34,19 @@ public class MailMessageForwarder implements MessageForwarder {
mimeMessageHelper.setReplyTo(from);
mimeMessageHelper.setTo(receivers.toArray(new String[0]));
mimeMessageHelper.setSubject(subject);
mimeMessageHelper.setText(content);
mimeMessageHelper.setText(formatMail(content));
this.javaMailSender.send(mimeMessage);
}
private String formatMail(String content) {
StringBuilder sb = new StringBuilder(content);
sb.append("\n\n")
.append("-----------------------------------\n")
.append("Send via nclazz mail relay");
return sb.toString();
}
}

View File

@ -47,7 +47,7 @@ public class MessageFormController {
redirect = form.getOnSuccess();
}
return "redirect:" + redirect;
return "redirect:" + addRefererToRelativeUrl(referer, redirect);
}
private String formatErrorRedirect(String referer, MessageForm form, BindingResult bindingResult) {
@ -58,7 +58,14 @@ public class MessageFormController {
.collect(Collectors.joining("&"));
String origin = form.getOnError() != null ? form.getOnError() : referer;
return origin + "?" + queryParams;
return addRefererToRelativeUrl(referer, origin) + "?" + queryParams;
}
private String addRefererToRelativeUrl(String referer, String url) {
if(!url.startsWith("/")) {
return url;
}
return referer + url;
}
private static String mapValidationErrorToQueryParam(ValidationError error) {