From 9e81d6d7fae6722869160cc119930f67f4691640 Mon Sep 17 00:00:00 2001 From: krSeonghyeon <149303551+krSeonghyeon@users.noreply.github.com> Date: Thu, 7 Nov 2024 22:25:10 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20?= =?UTF-8?q?=EC=8B=9C=20=EA=B0=95=EC=A0=9C=20=EA=B5=AC=EB=8F=85=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20(#1002)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 회원가입 시 강제 구독 삭제 * fix: 모든 회원이 아닌 device 토큰이 존재하는 회원만 추가하도록 변경 * chore: 미사용 코드 삭제 * chore: 개행추가 --- .../koin/domain/student/model/StudentEventListener.java | 3 --- .../koin/domain/student/model/StudentRegisterEvent.java | 3 +-- .../koin/domain/student/service/StudentService.java | 2 +- .../V92__delete_notification_subscribe_review_prompt.sql | 8 ++++++++ 4 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 src/main/resources/db/migration/V92__delete_notification_subscribe_review_prompt.sql diff --git a/src/main/java/in/koreatech/koin/domain/student/model/StudentEventListener.java b/src/main/java/in/koreatech/koin/domain/student/model/StudentEventListener.java index dc1d8e35c..cfedb433d 100644 --- a/src/main/java/in/koreatech/koin/domain/student/model/StudentEventListener.java +++ b/src/main/java/in/koreatech/koin/domain/student/model/StudentEventListener.java @@ -20,7 +20,6 @@ public class StudentEventListener { private final SlackClient slackClient; private final SlackNotificationFactory slackNotificationFactory; - private final NotificationService notificationService; @TransactionalEventListener(phase = AFTER_COMMIT) public void onStudentEmailRequest(StudentEmailRequestEvent event) { @@ -32,7 +31,5 @@ public void onStudentEmailRequest(StudentEmailRequestEvent event) { public void onStudentRegister(StudentRegisterEvent event) { var notification = slackNotificationFactory.generateStudentRegisterCompleteNotification(event.email()); slackClient.sendMessage(notification); - - notificationService.permitNotificationSubscribe(event.studentId(), NotificationSubscribeType.REVIEW_PROMPT); } } diff --git a/src/main/java/in/koreatech/koin/domain/student/model/StudentRegisterEvent.java b/src/main/java/in/koreatech/koin/domain/student/model/StudentRegisterEvent.java index 01092f04a..4fe083c00 100644 --- a/src/main/java/in/koreatech/koin/domain/student/model/StudentRegisterEvent.java +++ b/src/main/java/in/koreatech/koin/domain/student/model/StudentRegisterEvent.java @@ -1,8 +1,7 @@ package in.koreatech.koin.domain.student.model; public record StudentRegisterEvent( - String email, - Integer studentId + String email ) { } 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 e2b6c3b47..cdc41a261 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 @@ -136,7 +136,7 @@ public ModelAndView authenticate(AuthTokenRequest request) { userRepository.save(student.getUser()); studentRedisRepository.deleteById(student.getUser().getEmail()); - eventPublisher.publishEvent(new StudentRegisterEvent(student.getUser().getEmail(), student.getId())); + eventPublisher.publishEvent(new StudentRegisterEvent(student.getUser().getEmail())); return new ModelAndView("success_register_config"); } diff --git a/src/main/resources/db/migration/V92__delete_notification_subscribe_review_prompt.sql b/src/main/resources/db/migration/V92__delete_notification_subscribe_review_prompt.sql new file mode 100644 index 000000000..9175d1fcd --- /dev/null +++ b/src/main/resources/db/migration/V92__delete_notification_subscribe_review_prompt.sql @@ -0,0 +1,8 @@ +DELETE FROM notification_subscribe +WHERE subscribe_type = 'REVIEW_PROMPT'; + +INSERT INTO notification_subscribe (created_at, updated_at, subscribe_type, user_id) +SELECT NOW(), NOW(), 'REVIEW_PROMPT', s.user_id +FROM students s + JOIN users u ON s.user_id = u.id +WHERE u.device_token IS NOT NULL;