-
Notifications
You must be signed in to change notification settings - Fork 2
refactor : 이메일 검증 API #364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
9fe635e
cb1a7c8
4274af8
666fecd
2b9950f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| import java.util.concurrent.CompletableFuture; | ||
|
|
||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.mail.javamail.JavaMailSender; | ||
| import org.springframework.mail.javamail.MimeMessageHelper; | ||
| import org.springframework.retry.annotation.Recover; | ||
|
|
@@ -15,6 +16,7 @@ | |
| import com.gamzabat.algohub.enums.EmailType; | ||
| import com.gamzabat.algohub.exception.MessagingRuntimeException; | ||
|
|
||
| import jakarta.annotation.PostConstruct; | ||
| import jakarta.mail.MessagingException; | ||
| import jakarta.mail.internet.MimeMessage; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
@@ -24,9 +26,13 @@ | |
| @RequiredArgsConstructor | ||
| @Slf4j | ||
| public class EmailService { | ||
|
|
||
| @Value("${spring.profiles.active:dev}") | ||
| private String activeProfile; | ||
|
|
||
| private static final String FROM_ADDRESS = "noreply@algohub.kr"; | ||
| private static final String EMAIL_VERIFICATION_CLIENT_ENDPOINT = "https://algohub.kr/signup"; | ||
| private static final String RESET_PASSWORD_CLIENT_ENDPOINT = "https://algohub.kr/reset-password"; | ||
| private String EMAIL_VERIFICATION_CLIENT_ENDPOINT; | ||
| private String RESET_PASSWORD_CLIENT_ENDPOINT; | ||
| private final JavaMailSender mailSender; | ||
| private final TemplateEngine templateEngine; | ||
|
|
||
|
|
@@ -51,7 +57,6 @@ private void sendMail(String recipient, EmailType type, String content) { | |
| try { | ||
| MimeMessage message = mailSender.createMimeMessage(); | ||
| MimeMessageHelper helper = new MimeMessageHelper(message, true, "UTF-8"); | ||
|
|
||
| helper.setTo(recipient); | ||
| helper.setFrom(FROM_ADDRESS); | ||
| helper.setSubject(getEmailSubject(type)); | ||
|
|
@@ -102,4 +107,20 @@ private String getEmailSubject(EmailType type) { | |
| default -> throw new IllegalArgumentException("LOGIC ERROR : Unreachable code block"); | ||
| }; | ||
| } | ||
|
|
||
| @PostConstruct | ||
| private void init() { | ||
| this.EMAIL_VERIFICATION_CLIENT_ENDPOINT = createClientEndpoint("signup"); | ||
| this.RESET_PASSWORD_CLIENT_ENDPOINT = createClientEndpoint("reset-password"); | ||
| } | ||
|
|
||
|
||
| private String createClientEndpoint(String apiType) { | ||
| System.out.println(activeProfile); | ||
|
||
|
|
||
| if ("prod".equals(activeProfile)) { | ||
| return ("https://algohub.kr/" + apiType); | ||
| } else { | ||
| return ("https://rc.algohub.kr/" + apiType); | ||
| } | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ??????????????? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이제 상수가 아니니까 선언을 제거하고, 함수 내부에서 변수로 선언해주세요. 네이밍 케이스도 카멜케이스로 수정 부탁드리구요