From dfe8a318fded5e6009d556154d9f6a89ad8cda83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9C=A0=EC=A0=95?= Date: Sun, 29 Dec 2024 22:51:45 +0900 Subject: [PATCH] =?UTF-8?q?=08fix:=20=EB=AF=B8=EC=85=98=20=EC=A1=B0?= =?UTF-8?q?=EC=9D=B8=20=ED=91=B8=EC=8B=9C=20=EC=95=8C=EB=A6=BC=20(#116)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/firebase/PushMessageSenderImpl.java | 13 ++++++++----- .../application/mission/MissionMemberService.java | 7 ------- .../nexters/goalpanzi/domain/mission/Mission.java | 4 ++-- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/nexters/goalpanzi/application/firebase/PushMessageSenderImpl.java b/src/main/java/com/nexters/goalpanzi/application/firebase/PushMessageSenderImpl.java index 0361e3f..8187850 100644 --- a/src/main/java/com/nexters/goalpanzi/application/firebase/PushMessageSenderImpl.java +++ b/src/main/java/com/nexters/goalpanzi/application/firebase/PushMessageSenderImpl.java @@ -1,16 +1,15 @@ package com.nexters.goalpanzi.application.firebase; -import com.google.firebase.messaging.FirebaseMessaging; -import com.google.firebase.messaging.FirebaseMessagingException; -import com.google.firebase.messaging.Message; -import com.google.firebase.messaging.Notification; +import com.google.firebase.messaging.*; import com.nexters.goalpanzi.exception.BaseException; import com.nexters.goalpanzi.exception.ErrorCode; import com.nexters.goalpanzi.infrastructure.firebase.PushMessageSender; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import java.util.Map; +@Slf4j @Component public class PushMessageSenderImpl implements PushMessageSender { @@ -85,7 +84,11 @@ private void sendMessage(final Message message, final ErrorCode errorCode) { try { FirebaseMessaging.getInstance().send(message); } catch (FirebaseMessagingException e) { - throw new BaseException(errorCode, e); + if (e.getMessagingErrorCode().equals(MessagingErrorCode.UNREGISTERED)) { + log.info("더 이상 사용되지 않는 토큰입니다."); + } else { + throw new BaseException(errorCode, e); + } } } } diff --git a/src/main/java/com/nexters/goalpanzi/application/mission/MissionMemberService.java b/src/main/java/com/nexters/goalpanzi/application/mission/MissionMemberService.java index 7b3ecb0..d5a3067 100644 --- a/src/main/java/com/nexters/goalpanzi/application/mission/MissionMemberService.java +++ b/src/main/java/com/nexters/goalpanzi/application/mission/MissionMemberService.java @@ -20,7 +20,6 @@ import com.nexters.goalpanzi.exception.NotFoundException; import com.nexters.goalpanzi.infrastructure.firebase.PushMessageSender; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -33,7 +32,6 @@ import static com.nexters.goalpanzi.domain.firebase.PushMessage.MISSION_CANCELLATION_WARNING; import static com.nexters.goalpanzi.domain.firebase.PushMessage.MISSION_READY; -@Slf4j @Transactional(readOnly = true) @RequiredArgsConstructor @Service @@ -84,12 +82,7 @@ private void validateAlreadyJoin(final Member member, final Mission mission) { }); } - // FIXME: 호스트에게 알림 가는 데 확인 필요 private void sendJoinPushMessage(final Member member, final Mission mission) { - // TODO: 오류 확인 후 삭제 - log.info("Host member: " + mission.getHostMemberId()); - log.info("Join member: " + member.getId()); - if (mission.isHostMember(member.getId())) { return; } diff --git a/src/main/java/com/nexters/goalpanzi/domain/mission/Mission.java b/src/main/java/com/nexters/goalpanzi/domain/mission/Mission.java index af30533..d4b7bdd 100644 --- a/src/main/java/com/nexters/goalpanzi/domain/mission/Mission.java +++ b/src/main/java/com/nexters/goalpanzi/domain/mission/Mission.java @@ -220,11 +220,11 @@ public boolean isEndDate(final LocalDate today) { /** * 미션 호스트인지 검증 * - * @param memberId + * @param memberId 멤버 아이디 * @return 미션 호스트(생성한 사람) 여부 */ public boolean isHostMember(final Long memberId) { - return hostMemberId == memberId; + return hostMemberId.equals(memberId); } @Override