Skip to content

Commit

Permalink
FIX : Version matching about whole code of all branches
Browse files Browse the repository at this point in the history
  • Loading branch information
yummygyudon committed Nov 16, 2023
1 parent d65bfec commit 1ef0cd0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,7 +17,6 @@
import org.springframework.web.client.RestTemplate;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

@Service
Expand Down Expand Up @@ -84,30 +84,22 @@ public PushTokenResponse.StatusResponse registerDeviceToken(User user, String pu

// 유효하지 않은 토큰으로 인해 BadRequest가 발생하더라도 넘어가야함.(Local 에는 모든 토큰을 쌓아놓기 때문에)
@Transactional
public PushTokenResponse.StatusResponse deleteDeviceToken(User user, String pushToken) {
Optional<PushToken> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1ef0cd0

Please sign in to comment.