From 1ef0cd00a54080255f3f34a214734d67770e466c Mon Sep 17 00:00:00 2001 From: yummygyudon Date: Thu, 16 Nov 2023 18:41:33 +0900 Subject: [PATCH] FIX : Version matching about whole code of all branches --- .../notification/PushTokenService.java | 40 ++++++++----------- .../user/UserPushTokenController.java | 1 + .../user/UserWithdrawController.java | 1 + 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/sopt/app/application/notification/PushTokenService.java b/src/main/java/org/sopt/app/application/notification/PushTokenService.java index d6f96b82..bcd8e02f 100644 --- a/src/main/java/org/sopt/app/application/notification/PushTokenService.java +++ b/src/main/java/org/sopt/app/application/notification/PushTokenService.java @@ -3,6 +3,7 @@ import lombok.RequiredArgsConstructor; import lombok.val; import org.sopt.app.common.exception.BadRequestException; +import org.sopt.app.common.response.ErrorCode; import org.sopt.app.domain.entity.PushToken; import org.sopt.app.domain.entity.User; import org.sopt.app.domain.enums.PushTokenPlatform; @@ -16,7 +17,6 @@ import org.springframework.web.client.RestTemplate; import java.util.List; -import java.util.Optional; import java.util.UUID; @Service @@ -84,30 +84,22 @@ public PushTokenResponse.StatusResponse registerDeviceToken(User user, String pu // 유효하지 않은 토큰으로 인해 BadRequest가 발생하더라도 넘어가야함.(Local 에는 모든 토큰을 쌓아놓기 때문에) @Transactional - public PushTokenResponse.StatusResponse deleteDeviceToken(User user, String pushToken) { - Optional targetToken = pushTokenRepository.findByUserIdAndToken(user.getId(), pushToken); - if (targetToken.isPresent()) { - try { - val entity = new HttpEntity( - createBodyFor(targetToken.get()), - createHeadersFor(ACTION_DELETE, targetToken.get().getPlatform().name()) - ); - val response = sendRequestToPushServer(entity); - pushTokenRepository.delete(targetToken.get()); - return response.getBody(); - } catch (BadRequestException e) { - return PushTokenResponse.StatusResponse.builder() - .status(e.getStatusCode().value()) - .success(false) - .message(e.getResponseMessage()) - .build(); - } + public PushTokenResponse.StatusResponse deleteDeviceToken(PushToken pushToken) { + try { + val entity = new HttpEntity( + createBodyFor(pushToken), + createHeadersFor(ACTION_DELETE, pushToken.getPlatform().name()) + ); + val response = sendRequestToPushServer(entity); + pushTokenRepository.delete(pushToken); + return response.getBody(); + } catch (BadRequestException e) { + return PushTokenResponse.StatusResponse.builder() + .status(e.getStatusCode().value()) + .success(false) + .message(e.getResponseMessage()) + .build(); } - return PushTokenResponse.StatusResponse.builder() - .status(HttpStatus.OK.value()) - .success(true) - .message("토큰 삭제 성공") - .build(); } @Transactional diff --git a/src/main/java/org/sopt/app/presentation/user/UserPushTokenController.java b/src/main/java/org/sopt/app/presentation/user/UserPushTokenController.java index e478a16b..fd22cf3a 100644 --- a/src/main/java/org/sopt/app/presentation/user/UserPushTokenController.java +++ b/src/main/java/org/sopt/app/presentation/user/UserPushTokenController.java @@ -9,6 +9,7 @@ import lombok.RequiredArgsConstructor; import lombok.val; import org.sopt.app.application.notification.PushTokenService; +import org.sopt.app.domain.entity.PushToken; import org.sopt.app.domain.entity.User; import org.sopt.app.presentation.notification.*; import org.springframework.http.HttpStatus; diff --git a/src/main/java/org/sopt/app/presentation/user/UserWithdrawController.java b/src/main/java/org/sopt/app/presentation/user/UserWithdrawController.java index 71815a0f..39ff9a48 100644 --- a/src/main/java/org/sopt/app/presentation/user/UserWithdrawController.java +++ b/src/main/java/org/sopt/app/presentation/user/UserWithdrawController.java @@ -9,6 +9,7 @@ import org.sopt.app.application.notification.PushTokenService; import org.sopt.app.application.stamp.StampService; import org.sopt.app.application.user.UserService; +import org.sopt.app.domain.entity.PushToken; import org.sopt.app.domain.entity.User; import org.sopt.app.presentation.notification.PushTokenRequest; import org.sopt.app.presentation.notification.PushTokenResponse;