Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/hotfix/swagger' into dev-check
Browse files Browse the repository at this point in the history
  • Loading branch information
versatile0010 committed Nov 23, 2023
2 parents f233147 + eb729f7 commit 840700d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@
@AllArgsConstructor
@Builder
public class SaveDisasterRequest {
@Schema(defaultValue = "HEAVY_RAIN")
private DisasterType disasterType;
@Schema(defaultValue = "서울특별시 성동구 성수동")
private String location;
@Schema(defaultValue = """
[서울특별시] 오늘 15시40분 현재 서울지역에 많은 비가 내리고 있습니다.
산지와 하천 등 위험지역에 접근하지 마시고, 기상정보를 확인하여 대비 바랍니다.
""")
private String msg;
private Long disasterNum;
@Schema(defaultValue = "2023/11/21 23:22:00")
@Schema(defaultValue = "2023/11/25 15:40:00")
private String createdAt;

public static SaveDisasterRequest of(DisasterType disasterType, String location, String msg, Long disasterNum, String createdAt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void sendFcmsPresentLocationAndOnboardingDisasterType(DisasterEvent disas
List<DisasterType> enableDisasterTypes = notificationDisasterRepository.findAllByMemberId(memberId)
.stream().map(NotificationDisaster::getDisasterType).toList();
return enableDisasterTypes.contains(disasterEvent.getType());
}).map(memberId -> {
}).toList().stream().map(memberId -> {
Member member = memberRepository.findById(memberId)
.orElseThrow(NotFoundMemberException::new);
NotificationEntity savedNotificationEntity = notificationRepository.save(
Expand Down Expand Up @@ -89,20 +89,27 @@ public void sendFcmsPresentLocationAndOnboardingDisasterType(DisasterEvent disas
.toList();


log.info("회원이 재난문자 알림을 받고자 하는 지역에 대한 푸시알람을 중복을 제거하여 보냅니다.");
log.info("회원이 재난문자 알림을 받고자 하는 지역에 대한 푸시알람을 중복을 제거하여 보냅니다. 이때 재난 유형도 필터링합니다.");
// 해당 회원의 온보딩 리스트 및 알림을 허용하는 재난 유형을 기준으로 알림을 보낸다.
List<String> targetFcmsByOnboardingRegionsAndDisasterTypes = distinctMemberIdListByOnboardingRegions.stream()
.flatMap(memberId -> {
Member member = memberRepository.findById(memberId)
.orElseThrow(NotFoundMemberException::new);
boolean isMatched = notificationRegionRepository.findByMemberId(memberId)
boolean isRegionMatched = notificationRegionRepository.findByMemberId(memberId)
.stream().anyMatch(
region -> region.getLocation().contains(disasterLocation)
);
notificationRepository.save(
new NotificationEntity(member, disasterEvent.getType(), disasterEvent.getMessage(), true, disasterLocation)
);
return isMatched ? Stream.of(member.getFcmToken()) : null;
// <-------- 요부분
List<DisasterType> enableDisasterTypes = notificationDisasterRepository.findAllByMemberId(memberId)
.stream().map(NotificationDisaster::getDisasterType).toList();
boolean isDisasterTypeMatched = enableDisasterTypes.contains(disasterEvent.getType());

if(isRegionMatched && isDisasterTypeMatched) {
notificationRepository.save(
new NotificationEntity(member, disasterEvent.getType(), disasterEvent.getMessage(), true, disasterLocation)
);
}
return (isRegionMatched && isDisasterTypeMatched) ? Stream.of(member.getFcmToken()) : null;
}).filter(Objects::nonNull).toList();
fcmMessageProvider.sendFcmToMembers(targetFcmsByOnboardingRegionsAndDisasterTypes, title, message, NotificationTag.DISASTER);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public NotificationEntity(Member member,
case MISSING -> this.tagDetail = "실종";
case OTHERS -> this.tagDetail = "기타";
}
this.title = String.format("%s 사고 발생!", tagDetail);
this.title = String.format("%s %s 발생",location, tagDetail);
}

}

0 comments on commit 840700d

Please sign in to comment.