diff --git a/src/main/java/in/koreatech/koin/common/event/UserMarketingAgreementEvent.java b/src/main/java/in/koreatech/koin/common/event/UserMarketingAgreementEvent.java index 7a87ef421c..8f4faf5e2b 100644 --- a/src/main/java/in/koreatech/koin/common/event/UserMarketingAgreementEvent.java +++ b/src/main/java/in/koreatech/koin/common/event/UserMarketingAgreementEvent.java @@ -1,8 +1,7 @@ package in.koreatech.koin.common.event; public record UserMarketingAgreementEvent( - Integer userId, - boolean marketingNotificationAgreement + Integer userId ) { } diff --git a/src/main/java/in/koreatech/koin/domain/notification/eventlistener/NotificationEventListener.java b/src/main/java/in/koreatech/koin/domain/notification/eventlistener/NotificationEventListener.java index 889fb994d2..667453f37e 100644 --- a/src/main/java/in/koreatech/koin/domain/notification/eventlistener/NotificationEventListener.java +++ b/src/main/java/in/koreatech/koin/domain/notification/eventlistener/NotificationEventListener.java @@ -12,14 +12,12 @@ @Component @RequiredArgsConstructor @Profile("!test") -public class NotificationEventListener { // TODO : 리팩터링 필요 (비즈니스로직 제거 및 알림 책임만 갖도록) +public class NotificationEventListener { private final NotificationService notificationService; @TransactionalEventListener public void onUserRegisterEvent(UserMarketingAgreementEvent event) { - if (event.marketingNotificationAgreement()) { - notificationService.permitNotificationSubscribe(event.userId(), NotificationSubscribeType.MARKETING); - } + notificationService.permitNotificationSubscribe(event.userId(), NotificationSubscribeType.MARKETING); } } diff --git a/src/main/java/in/koreatech/koin/domain/student/service/StudentService.java b/src/main/java/in/koreatech/koin/domain/student/service/StudentService.java index c53bfce8a5..ea6dd90f32 100644 --- a/src/main/java/in/koreatech/koin/domain/student/service/StudentService.java +++ b/src/main/java/in/koreatech/koin/domain/student/service/StudentService.java @@ -11,13 +11,11 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.servlet.ModelAndView; -import in.koreatech.koin.global.auth.JwtProvider; -import in.koreatech.koin.global.concurrent.ConcurrencyGuard; +import in.koreatech.koin.admin.abtest.useragent.UserAgentInfo; import in.koreatech.koin.common.event.StudentFindPasswordEvent; import in.koreatech.koin.common.event.StudentRegisterEvent; import in.koreatech.koin.common.event.StudentRegisterRequestEvent; import in.koreatech.koin.common.event.UserMarketingAgreementEvent; -import in.koreatech.koin.admin.abtest.useragent.UserAgentInfo; import in.koreatech.koin.domain.graduation.repository.StandardGraduationRequirementsRepository; import in.koreatech.koin.domain.graduation.service.GraduationService; import in.koreatech.koin.domain.student.dto.RegisterStudentRequest; @@ -54,6 +52,8 @@ import in.koreatech.koin.domain.user.service.UserService; import in.koreatech.koin.domain.user.service.UserValidationService; import in.koreatech.koin.domain.user.verification.service.UserVerificationService; +import in.koreatech.koin.global.auth.JwtProvider; +import in.koreatech.koin.global.concurrent.ConcurrencyGuard; import lombok.RequiredArgsConstructor; @Service @@ -310,9 +310,9 @@ public void studentRegisterV2(RegisterStudentRequestV2 request) { Student student = request.toStudent(passwordEncoder, department); studentRepository.save(student); userRepository.save(student.getUser()); - eventPublisher.publishEvent( - new UserMarketingAgreementEvent(student.getUser().getId(), request.marketingNotificationAgreement()) - ); + if (request.marketingNotificationAgreement()) { + eventPublisher.publishEvent(new UserMarketingAgreementEvent(student.getUser().getId())); + } eventPublisher.publishEvent(new StudentRegisterEvent(student.getUser().getPhoneNumber())); userVerificationService.consumeVerification(request.phoneNumber()); } diff --git a/src/main/java/in/koreatech/koin/domain/user/service/UserService.java b/src/main/java/in/koreatech/koin/domain/user/service/UserService.java index e934968951..2b0429b237 100644 --- a/src/main/java/in/koreatech/koin/domain/user/service/UserService.java +++ b/src/main/java/in/koreatech/koin/domain/user/service/UserService.java @@ -74,9 +74,9 @@ public void registerUser(UserRegisterRequest request) { ); User user = request.toUser(passwordEncoder); userRepository.save(user); - eventPublisher.publishEvent( - new UserMarketingAgreementEvent(user.getId(), request.marketingNotificationAgreement()) - ); + if (request.marketingNotificationAgreement()) { + eventPublisher.publishEvent(new UserMarketingAgreementEvent(user.getId())); + } eventPublisher.publishEvent(new UserRegisterEvent(user.getPhoneNumber())); userVerificationService.consumeVerification(request.phoneNumber()); }