Migrate to springboot emai.
parent
88d5f0df43
commit
e3998ef3d4
|
@ -12,6 +12,5 @@ import org.springframework.context.annotation.ImportResource;
|
||||||
@ComponentScan(basePackageClasses = {AuthenticationProvider.class, MindmapServiceImpl.class, LabelManagerImpl.class, VelocityEngineUtils.class})
|
@ComponentScan(basePackageClasses = {AuthenticationProvider.class, MindmapServiceImpl.class, LabelManagerImpl.class, VelocityEngineUtils.class})
|
||||||
@Import({JPAConfig.class, SecurityConfig.class})
|
@Import({JPAConfig.class, SecurityConfig.class})
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@ImportResource(value = {"classpath:spring/wisemapping-mail.xml"})
|
|
||||||
public class CommonConfig {
|
public class CommonConfig {
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class RestAppConfig {
|
||||||
}))
|
}))
|
||||||
.csrf(AbstractHttpConfigurer::disable)
|
.csrf(AbstractHttpConfigurer::disable)
|
||||||
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||||
// .httpBasic(withDefaults())
|
.httpBasic(withDefaults())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,21 +38,18 @@ public final class MailerService {
|
||||||
|
|
||||||
//~ Instance fields ......................................................................................
|
//~ Instance fields ......................................................................................
|
||||||
|
|
||||||
// @Autowired
|
@Autowired
|
||||||
private JavaMailSender mailSender;
|
private JavaMailSender mailSender;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private VelocityEngineWrapper velocityEngineWrapper;
|
private VelocityEngineWrapper velocityEngineWrapper;
|
||||||
|
|
||||||
@Value("${mail.serverSendEmail}")
|
@Value("${app.mail.serverSendEmail}")
|
||||||
private String serverFromEmail;
|
private String serverFromEmail;
|
||||||
|
|
||||||
@Value("${mail.supportEmail}")
|
@Value("${app.mail.supportEmail}")
|
||||||
private String supportEmail;
|
private String supportEmail;
|
||||||
|
|
||||||
@Value("${mail.errorReporterEmail:}")
|
|
||||||
private String errorReporterEmail;
|
|
||||||
|
|
||||||
//~ Methods ..............................................................................................
|
//~ Methods ..............................................................................................
|
||||||
|
|
||||||
public String getServerSenderEmail() {
|
public String getServerSenderEmail() {
|
||||||
|
@ -86,8 +83,4 @@ public final class MailerService {
|
||||||
public String getSupportEmail() {
|
public String getSupportEmail() {
|
||||||
return supportEmail;
|
return supportEmail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getErrorReporterEmail() {
|
|
||||||
return errorReporterEmail;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright [2022] [wisemapping]
|
|
||||||
*
|
|
||||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
|
||||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
|
||||||
* "powered by wisemapping" text requirement on every single page;
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the license at
|
|
||||||
*
|
|
||||||
* http://www.wisemapping.org/license
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.wisemapping.service;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.springframework.util.DigestUtils;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class NotifierFilter {
|
|
||||||
public static final int MAX_CACHE_ENTRY = 500;
|
|
||||||
private final Map<String, String> emailByMd5 = Collections.synchronizedMap(new LinkedHashMap<String, String>() {
|
|
||||||
protected boolean removeEldestEntry(Map.Entry eldest) {
|
|
||||||
return size() > MAX_CACHE_ENTRY;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
public boolean hasBeenSend(@NotNull final String email, @NotNull final Map<String, String> model) {
|
|
||||||
|
|
||||||
final StringBuilder buff = new StringBuilder();
|
|
||||||
for (String key : model.keySet()) {
|
|
||||||
if (!key.equals("mapXML")) {
|
|
||||||
buff.append(key);
|
|
||||||
buff.append("=");
|
|
||||||
buff.append(model.get(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final String digest = DigestUtils.md5DigestAsHex(buff.toString().getBytes());
|
|
||||||
boolean result = emailByMd5.containsKey(digest);
|
|
||||||
if (!result) {
|
|
||||||
emailByMd5.put(digest, email);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,6 +1,17 @@
|
||||||
# SpringBoot Configuration ...
|
# SpringBoot Configuration ...
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
|
mail:
|
||||||
|
host: smtp.example.com
|
||||||
|
port: 25
|
||||||
|
username: setusername
|
||||||
|
password: setpassword
|
||||||
|
properties:
|
||||||
|
mail:
|
||||||
|
smtp:
|
||||||
|
connectiontimeout: 5000
|
||||||
|
timeout: 3000
|
||||||
|
writetimeout: 5000
|
||||||
output:
|
output:
|
||||||
ansi:
|
ansi:
|
||||||
enabled=always:
|
enabled=always:
|
||||||
|
@ -38,13 +49,20 @@ logging:
|
||||||
root: TRACE
|
root: TRACE
|
||||||
|
|
||||||
# Application Configuration.
|
# Application Configuration.
|
||||||
|
|
||||||
app:
|
app:
|
||||||
jwt:
|
jwt:
|
||||||
secret: dlqxKAg685SaKhsQXIMeM=JWCw3bkl3Ei3Tb7LMlnd19oMd66burPNlJ0Po1qguyjgpakQTk2CN3
|
secret: dlqxKAg685SaKhsQXIMeM=JWCw3bkl3Ei3Tb7LMlnd19oMd66burPNlJ0Po1qguyjgpakQTk2CN3
|
||||||
expirationMin: 10080 # One week
|
expirationMin: 10080 # One week
|
||||||
admin:
|
admin:
|
||||||
user: admin@wisemapping.org
|
user: admin@wisemapping.org
|
||||||
|
mail:
|
||||||
|
serverSendEmail: root@localhost
|
||||||
|
supportEmail: root@localhost
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
google:
|
google:
|
||||||
ads:
|
ads:
|
||||||
|
@ -56,18 +74,6 @@ google:
|
||||||
enabled: true
|
enabled: true
|
||||||
secretKey: 6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe
|
secretKey: 6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe
|
||||||
siteKey: 6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
|
siteKey: 6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
|
||||||
mail:
|
|
||||||
password: ''
|
|
||||||
serverSendEmail: root@localhost
|
|
||||||
smtp:
|
|
||||||
auth: false
|
|
||||||
host: localhost
|
|
||||||
port: 25
|
|
||||||
quitwait: false
|
|
||||||
starttls:
|
|
||||||
enable: false
|
|
||||||
supportEmail: root@localhost
|
|
||||||
username: root
|
|
||||||
security:
|
security:
|
||||||
oauth2:
|
oauth2:
|
||||||
google:
|
google:
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
||||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
|
||||||
|
|
||||||
|
|
||||||
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
|
|
||||||
<property name="host" value="${mail.smtp.host}"/>
|
|
||||||
<property name="port" value="${mail.smtp.port}"/>
|
|
||||||
<property name="protocol" value="smtp"/>
|
|
||||||
<property name="username" value="${mail.username}"/>
|
|
||||||
<property name="password" value="${mail.password}"/>
|
|
||||||
<property name="javaMailProperties">
|
|
||||||
<props>
|
|
||||||
<prop key="mail.smtp.auth">${mail.smtp.auth:false}</prop>
|
|
||||||
<prop key="mail.smtp.starttls.enable">${mail.smtp.starttls.enable:false}</prop>
|
|
||||||
<prop key="mail.smtp.quitwait">${mail.smtp.quitwait:true}</prop>
|
|
||||||
</props>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
|
|
||||||
<property name="defaultEncoding" value="UTF-8"/>
|
|
||||||
<property name="basenames">
|
|
||||||
<list>
|
|
||||||
<value>messages</value>
|
|
||||||
</list>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
</beans>
|
|
Loading…
Reference in New Issue