Skip to content

Commit

Permalink
�fix: 미션 조인 푸시 알림 (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
kimyu0218 authored Dec 29, 2024
1 parent 636d40f commit dfe8a31
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down Expand Up @@ -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);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ public boolean isEndDate(final LocalDate today) {
/**
* <b>미션 호스트인지 검증</b>
*
* @param memberId
* @param memberId 멤버 아이디
* @return 미션 호스트(생성한 사람) 여부
*/
public boolean isHostMember(final Long memberId) {
return hostMemberId == memberId;
return hostMemberId.equals(memberId);
}

@Override
Expand Down

0 comments on commit dfe8a31

Please sign in to comment.