Skip to content

Commit

Permalink
fix: remove concurrency from sendCode.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeqwaszx committed Jan 9, 2025
1 parent 76b0374 commit 1e8e26f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.waffletoy.team1server.account.controller

import com.waffletoy.team1server.account.AuthUser
import com.waffletoy.team1server.account.AuthenticateException
import com.waffletoy.team1server.account.EmailServiceException
import com.waffletoy.team1server.account.service.EmailService
import com.waffletoy.team1server.account.service.UserService
import io.swagger.v3.oas.annotations.Parameter
Expand All @@ -11,7 +10,6 @@ import org.springframework.beans.factory.annotation.Value
import org.springframework.http.ResponseCookie
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
import java.util.concurrent.CompletableFuture

@RestController
@RequestMapping("/api/user")
Expand All @@ -23,19 +21,9 @@ class UserController(
@PostMapping("/signup/send-code")
fun sendCode(
@RequestBody request: SendCodeRequest,
): CompletableFuture<ResponseEntity<Void>> {
return CompletableFuture.runAsync {
emailService.sendCode(request.snuMail)
}.handle { _, ex ->
if (ex != null) {
val cause = ex.cause ?: ex
if (cause is EmailServiceException) {
throw cause // Propagate the original EmailServiceException
}
throw RuntimeException("Unexpected error occurred", cause) // Wrap other exceptions
}
ResponseEntity.ok().build() // Return the successful response
}
): ResponseEntity<Void> {
emailService.sendCode(request.snuMail)
return ResponseEntity.ok().build() // Return the successful response
}

// 유저 이메일 인증 링크 클릭
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.mindrot.jbcrypt.BCrypt
import org.springframework.http.HttpStatus
import org.springframework.mail.SimpleMailMessage
import org.springframework.mail.javamail.JavaMailSender
import org.springframework.scheduling.annotation.Async
import org.springframework.stereotype.Service

@Service
Expand All @@ -15,7 +14,6 @@ class EmailService(
private val userRepository: UserRepository,
private val redisTokenService: RedisTokenService,
) {
@Async
fun sendCode(
snuMail: String,
) {
Expand Down

0 comments on commit 1e8e26f

Please sign in to comment.