Skip to content

Commit

Permalink
fix: 탈퇴, 차단 시 fcm토큰 지우기
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmondBreez3 committed Feb 6, 2024
1 parent ff5c3f8 commit 12f2b58
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.example.domains.user.enums.OauthProvider;
import com.example.domains.user.service.UserService;
import com.example.error.exception.InvalidOauthProviderException;
import com.example.fcm.adaptor.FcmTokenAdaptor;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -20,10 +21,13 @@ public class WithdrawUseCase {
private final UserAdaptor userAdaptor;
private final QuitDomainService quitDomainService;
private final UserService userService;
private final FcmTokenAdaptor fcmTokenAdaptor;
@Transactional
public void execute(String appleAccessToken, String referer, Long userId, Reason reason) {
User user = userAdaptor.findById(userId);
quitDomainService.save(Quit.of(userId, reason));
//Fcm쪽 탈퇴
fcmTokenAdaptor.execute(userId);
// oauth쪽 탈퇴
withdrawOauth(user.getOauthInfo().getProvider(), appleAccessToken, user, referer);
// 우리쪽 탈퇴
Expand All @@ -38,6 +42,8 @@ private void withdrawService(Long userId, User user) {
public void executeDev(String appleAccessToken) {
Long userId = SecurityUtil.getCurrentUserId();
User user = userAdaptor.findById(userId);
//Fcm쪽 탈퇴
fcmTokenAdaptor.execute(userId);
// oauth쪽 탈퇴
withdrawOauthDev(user.getOauthInfo().getProvider(), appleAccessToken, user);
// 우리쪽 탈퇴
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
import com.example.domains.block.entity.Block;
import com.example.domains.block.exception.exceptions.DuplicateBlockRequest;
import com.example.domains.block.repository.BlockRepository;
import com.example.fcm.adaptor.FcmTokenAdaptor;
import lombok.RequiredArgsConstructor;

@Adaptor
@RequiredArgsConstructor
public class BlockAdaptor {
private final BlockRepository blockRepository;
private final FcmTokenAdaptor fcmTokenAdaptor;
public void save(Long userId,Long reportedUserId, Long reviewId,Long popcornReviewId){
validateUser(userId,reviewId,popcornReviewId);
final Block result = Block.of(userId,reportedUserId,reviewId,popcornReviewId);
blockRepository.save(result);
fcmTokenAdaptor.execute(userId);
}

private void validateUser(Long userId, Long reviewId,Long popcornReviewId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.example.domains.user.enums.UserState;
import com.example.domains.userscreening.entity.QUserScreening;
import com.example.domains.userscreening.entity.UserScreening;
import com.example.fcm.adaptor.FcmTokenAdaptor;
import com.google.api.client.util.SecurityUtils;
import com.querydsl.core.types.Projections;
import com.querydsl.jpa.impl.JPAQueryFactory;
Expand All @@ -31,6 +32,7 @@ public class ReviewAdaptor {
private final ScreeningReviewRepository screeningReviewRepository;
private final BlockAdaptor blockAdaptor;
private final JPAQueryFactory queryFactory;
private final FcmTokenAdaptor fcmTokenAdaptor;

public void save(ScreeningReview screeningReview) {
screeningReviewRepository.save(screeningReview);
Expand Down Expand Up @@ -81,18 +83,22 @@ public void postComplain(Long reviewId,Long userId) {
ScreeningReview screeningReview = findById(reviewId);

blockAdaptor.save(userId,screeningReview.getUserScreening().getUser().getId(),reviewId,null);

System.out.println("testing");
int complainCount = screeningReview.getComplaintCount();
System.out.println(complainCount);
if (complainCount == 4) {
incrementComplaintCount(screeningReview);
// Get user from the screeningReview
User user = screeningReview.getUserScreening().getUser();

deActivateUser(user);
//DeviceToken삭제
fcmTokenAdaptor.execute(screeningReview.getUserScreening().getUser().getId());

// Delete the screeningReview
changeBlindStatus(screeningReview); // Assuming there is a method to delete screeningReview
} else {
System.out.println("test");
incrementComplaintCount(screeningReview);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public enum Genre {
ACTION("액션"),
WEST("서부극"),
GANG("갱스터"),
NOIRE("누아르"),
NOIRE("누와르"),
SUSPENSE("미스터리"),
THRILLER("스릴러"),
HORROR("공포"),
WAR("전쟁"),
SF("SF"),
DETECTIVE("참정"),
DETECTIVE("탐정"),
FANTASY("판타지"),
ADVENTURE("모험");

Expand Down

0 comments on commit 12f2b58

Please sign in to comment.