diff options
author | Vitaly Takmazov | 2020-03-07 16:01:52 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2020-03-07 16:01:52 +0300 |
commit | afb897034311fe7e0e981ec44100d3b3fd3ef39d (patch) | |
tree | 6104cab72b5eaae4b499e35b7bbc93be875e4336 /src/main/java/com/juick/server/api/Service.java | |
parent | c9d67837cbcaae84a03b7bd14e508ca62880f87f (diff) |
Load EmailManager conditionally
Diffstat (limited to 'src/main/java/com/juick/server/api/Service.java')
-rw-r--r-- | src/main/java/com/juick/server/api/Service.java | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/main/java/com/juick/server/api/Service.java b/src/main/java/com/juick/server/api/Service.java index 2763eab1..4474e4f0 100644 --- a/src/main/java/com/juick/server/api/Service.java +++ b/src/main/java/com/juick/server/api/Service.java @@ -27,6 +27,7 @@ import com.juick.server.util.HttpForbiddenException; import com.juick.service.EmailService; import com.juick.service.MessagesService; import com.juick.service.UserService; +import com.juick.service.component.AccountVerificationEvent; import com.juick.service.security.annotation.Visitor; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.IOUtils; @@ -36,6 +37,7 @@ import org.apache.commons.mail.util.MimeMessageParser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ExceptionHandler; @@ -70,7 +72,7 @@ public class Service { @Inject private CommandsManager commandsManager; @Inject - private EmailManager emailManager; + private ApplicationEventPublisher applicationEventPublisher; @Value("${api_user:juick}") private String serviceUser; @Value("${upload_tmp_dir:#{systemEnvironment['TEMP'] ?: '/tmp'}}") @@ -168,8 +170,7 @@ public class Service { if (!Arrays.asList(ignoredEmails).contains(from)) { String verificationCode = RandomStringUtils.randomAlphanumeric(8).toUpperCase(); emailService.addVerificationCode(null, from, verificationCode); - String signupUrl = String.format("Follow this link to create Juick account: https://juick.com/signup?type=email&hash=%s", verificationCode); - emailManager.sendEmail("noreply@juick.com", from, "Juick registration", signupUrl, StringUtils.EMPTY, Collections.emptyMap()); + applicationEventPublisher.publishEvent(new AccountVerificationEvent(this, from, verificationCode)); } } } else { |