Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
ori0o0p committed Jan 29, 2024
1 parent 983e169 commit 7f07ac8
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
import reactor.core.scheduler.Scheduler;

import java.io.UnsupportedEncodingException;
import java.util.Random;
Expand All @@ -21,10 +21,12 @@
public class MailSend {
private final AuthCodeRepository codeRepository;
private final JavaMailSender mailSender;
private final Scheduler scheduler;

public MailSend(AuthCodeRepository authCodeRepository, JavaMailSender javaMailSender) {
public MailSend(AuthCodeRepository authCodeRepository, JavaMailSender javaMailSender, Scheduler scheduler) {
this.codeRepository = authCodeRepository;
this.mailSender = javaMailSender;
this.scheduler = scheduler;
}

@Value("${admin.mail}")
Expand All @@ -36,8 +38,8 @@ public Mono<Void> execute(AuthCodeRequest request) {
String authCode = getRandomCode();
String mail = request.mail();

Mono<Void> sendMailMono = sendMail(mail, authCode).subscribeOn(Schedulers.boundedElastic());
Mono<Void> saveAuthCodeMono = saveAuthCode(mail, authCode).subscribeOn(Schedulers.boundedElastic());
Mono<Void> sendMailMono = sendMail(mail, authCode).subscribeOn(scheduler);
Mono<Void> saveAuthCodeMono = saveAuthCode(mail, authCode).subscribeOn(scheduler);

return Mono.when(sendMailMono,
saveAuthCodeMono);
Expand Down

0 comments on commit 7f07ac8

Please sign in to comment.