Skip to content

Commit

Permalink
fix: 없는 디바이스 토큰 조회시, 500에러 발생하는 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ehtjsv2 committed Aug 18, 2024
1 parent 80634f8 commit 34803d4
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
import com.happy.friendogly.footprint.repository.FootprintRepository;
import com.happy.friendogly.member.domain.Member;
import com.happy.friendogly.member.repository.MemberRepository;
import com.happy.friendogly.notification.domain.DeviceToken;
import com.happy.friendogly.notification.repository.DeviceTokenRepository;
import com.happy.friendogly.notification.service.NotificationService;
import com.happy.friendogly.pet.domain.Pet;
import com.happy.friendogly.pet.repository.PetRepository;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand Down Expand Up @@ -134,8 +136,9 @@ private List<String> findNearDeviceTokensWithoutMine(Footprint standardFootprint
return footprints.stream()
.filter(otherFootprint -> otherFootprint.isInsideBoundary(standardFootprint.getLocation())
&& otherFootprint.getMember() != member)
.map(otherFootprint -> otherFootprint.getMember().getId())
.map(otherMemberId -> deviceTokenRepository.findByMemberId(otherMemberId).get().getDeviceToken())
.map(otherFootprint -> deviceTokenRepository.findByMemberId(otherFootprint.getMember().getId()))
.flatMap(Optional::stream)
.map(DeviceToken::getDeviceToken)
.toList();
}
}

0 comments on commit 34803d4

Please sign in to comment.