mirror of https://github.com/halo-dev/halo
Remove useless reloadConfig in MailService
parent
ccb712d29c
commit
fd79c8db4d
|
@ -10,11 +10,6 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public interface MailService {
|
public interface MailService {
|
||||||
|
|
||||||
/**
|
|
||||||
* Reload email config.
|
|
||||||
*/
|
|
||||||
void reloadMailConfig();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a simple email
|
* Send a simple email
|
||||||
*
|
*
|
||||||
|
|
|
@ -5,9 +5,11 @@ import cn.hutool.core.util.StrUtil;
|
||||||
import freemarker.template.Template;
|
import freemarker.template.Template;
|
||||||
import io.github.biezhi.ome.OhMyEmail;
|
import io.github.biezhi.ome.OhMyEmail;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
|
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
|
||||||
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
|
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
|
||||||
|
import run.halo.app.event.options.OptionUpdatedEvent;
|
||||||
import run.halo.app.exception.EmailException;
|
import run.halo.app.exception.EmailException;
|
||||||
import run.halo.app.model.properties.EmailProperties;
|
import run.halo.app.model.properties.EmailProperties;
|
||||||
import run.halo.app.service.MailService;
|
import run.halo.app.service.MailService;
|
||||||
|
@ -38,18 +40,6 @@ public class MailServiceImpl implements MailService {
|
||||||
this.freeMarker = freeMarker;
|
this.freeMarker = freeMarker;
|
||||||
this.optionService = optionService;
|
this.optionService = optionService;
|
||||||
|
|
||||||
try {
|
|
||||||
reloadMailConfig();
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.warn("You have to configure the email settings correctly before using email service");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reloadMailConfig() {
|
|
||||||
loaded = false;
|
|
||||||
// Get default properties
|
|
||||||
loadConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,13 +130,9 @@ public class MailServiceImpl implements MailService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load email config.
|
* Loads email config.
|
||||||
*/
|
*/
|
||||||
private synchronized void loadConfig() {
|
private void loadConfig() {
|
||||||
if (loaded = true) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get default properties
|
// Get default properties
|
||||||
Properties defaultProperties = OhMyEmail.defaultConfig(log.isDebugEnabled());
|
Properties defaultProperties = OhMyEmail.defaultConfig(log.isDebugEnabled());
|
||||||
// Set smtp host
|
// Set smtp host
|
||||||
|
@ -157,8 +143,6 @@ public class MailServiceImpl implements MailService {
|
||||||
OhMyEmail.config(defaultProperties,
|
OhMyEmail.config(defaultProperties,
|
||||||
optionService.getByPropertyOfNonNull(EmailProperties.USERNAME).toString(),
|
optionService.getByPropertyOfNonNull(EmailProperties.USERNAME).toString(),
|
||||||
optionService.getByPropertyOfNonNull(EmailProperties.PASSWORD).toString());
|
optionService.getByPropertyOfNonNull(EmailProperties.PASSWORD).toString());
|
||||||
|
}
|
||||||
|
|
||||||
// Set config loaded with true
|
|
||||||
loaded = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue