diff --git a/src/main/java/org/rf/rfserver/apns/service/PushNotificationService.java b/src/main/java/org/rf/rfserver/apns/service/PushNotificationService.java index 5213bec5..74c895e1 100644 --- a/src/main/java/org/rf/rfserver/apns/service/PushNotificationService.java +++ b/src/main/java/org/rf/rfserver/apns/service/PushNotificationService.java @@ -56,6 +56,7 @@ public String buildPushNotificatoinPayload(PushNotificationType type, String tit } public void sendPushNotificationToUser(Long userId, String payload) { String deviceToken = (String) deviceTokenService.getDeviceTokenByUserId(userId); + if(deviceToken == null) return; sendPushNotification(deviceToken, payload); } public void sendPushNotification(String deviceToken, String payload) { diff --git a/src/main/java/org/rf/rfserver/chat/service/ChatPublisher.java b/src/main/java/org/rf/rfserver/chat/service/ChatPublisher.java index 07fd3ddd..79de66c2 100644 --- a/src/main/java/org/rf/rfserver/chat/service/ChatPublisher.java +++ b/src/main/java/org/rf/rfserver/chat/service/ChatPublisher.java @@ -79,7 +79,9 @@ public void sendMessage(ChatDto chatDto, Long partyId) { if(chatDto.getType() == TEXT || chatDto.getType() == IMAGE || chatDto.getType() == SCHEDULE || chatDto.getType() == REPLY) { Set userIds = partyidUseridService.getUserids(partyId); for (Long userId : userIds) { + if(userId == chatDto.getSpeaker().getUserId()) continue; String deviceToken = deviceTokenService.getDeviceTokenByUserId(userId); + if(deviceToken == null) continue; if(chatDto.getType() == TEXT || chatDto.getType() == REPLY) apnsService.sendPush(new PushDto(PushNotificationType.CHAT, userId, chatDto.getSpeaker().getUserName(), chatDto.getPartyName(), chat.getContent(),partyId)); if(chatDto.getType() == IMAGE) diff --git a/src/main/java/org/rf/rfserver/constant/Rule.java b/src/main/java/org/rf/rfserver/constant/Rule.java index be6115ce..f087ef8c 100644 --- a/src/main/java/org/rf/rfserver/constant/Rule.java +++ b/src/main/java/org/rf/rfserver/constant/Rule.java @@ -17,7 +17,7 @@ public enum Rule implements EnumModel{ ,NO_SEXUAL("선정적인 이야기 금지") ,POLITE_SPEECH("존댓말로 대화해요") ,INFORMAL_SPEECH("반말로 대화해요") - ,ACTIVE_VACATION("방학 떄도 활동할 사람을 원해요") + ,ACTIVE_VACATION("방학 때도 활동할 사람을 원해요") ,PURE("건전한 모임 활동을 원해요") ,DAILY_TALK("하루에 한 번 대화는 꼭 참여해요") ,FREE_MOOD("자유로운 분위기를 원해요") diff --git a/src/main/java/org/rf/rfserver/device/service/DeviceTokenService.java b/src/main/java/org/rf/rfserver/device/service/DeviceTokenService.java index 1f227278..4bf834df 100644 --- a/src/main/java/org/rf/rfserver/device/service/DeviceTokenService.java +++ b/src/main/java/org/rf/rfserver/device/service/DeviceTokenService.java @@ -1,12 +1,14 @@ package org.rf.rfserver.device.service; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.rf.rfserver.device.redisRepository.DeviceTokenRedisRepository; import org.rf.rfserver.redisDomain.DeviceToken; import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor +@Slf4j public class DeviceTokenService { private final DeviceTokenRedisRepository deviceTokenRedisRepository; public Boolean setDeviceToken(Long userId, String deviceToken) { @@ -14,7 +16,12 @@ public Boolean setDeviceToken(Long userId, String deviceToken) { return true; } public String getDeviceTokenByUserId(Long userId) { - return deviceTokenRedisRepository.findById(userId).get().getDeviceToken(); + try { + return deviceTokenRedisRepository.findById(userId).get().getDeviceToken(); + } catch(Exception e) { + log.info("No Device Token for : " + userId); + return null; + } } public Boolean deleteDeviceTokenByUserId(Long userId) { deviceTokenRedisRepository.deleteById(userId); diff --git a/src/main/java/org/rf/rfserver/party/dto/party/GetInterestPartyRes.java b/src/main/java/org/rf/rfserver/party/dto/party/GetInterestPartyRes.java index a38623dc..4f784a5a 100644 --- a/src/main/java/org/rf/rfserver/party/dto/party/GetInterestPartyRes.java +++ b/src/main/java/org/rf/rfserver/party/dto/party/GetInterestPartyRes.java @@ -17,11 +17,12 @@ public class GetInterestPartyRes { private Integer memberCount; private Long ownerId; private List interests; - + private Integer currentMemberCount; @Builder public GetInterestPartyRes(Long id, String name, String content, String imageFilePath, - LocalDateTime createdDate, int memberCount, Long ownerId, List interests) { + LocalDateTime createdDate, Integer memberCount, Long ownerId, List interests, + Integer currentMemberCount) { this.id = id; this.name = name; this.content = content; @@ -30,5 +31,6 @@ public GetInterestPartyRes(Long id, String name, String content, String imageFil this.memberCount = memberCount; this.ownerId = ownerId; this.interests = interests; + this.currentMemberCount = currentMemberCount; } } diff --git a/src/main/java/org/rf/rfserver/party/dto/party/PostPartyRes.java b/src/main/java/org/rf/rfserver/party/dto/party/PostPartyRes.java index 530256c4..99ea03ff 100644 --- a/src/main/java/org/rf/rfserver/party/dto/party/PostPartyRes.java +++ b/src/main/java/org/rf/rfserver/party/dto/party/PostPartyRes.java @@ -13,7 +13,7 @@ @AllArgsConstructor @Getter public class PostPartyRes { - private Long partyId; + private Long id; private String name; private String content; private String location; @@ -27,7 +27,7 @@ public class PostPartyRes { private List interests; public PostPartyRes(Long partyId, PostPartyReq postPartyReq, String imageFilePath) { - this.partyId = partyId; + this.id = partyId; this.name = postPartyReq.getName(); this.content = postPartyReq.getContent(); this.location = postPartyReq.getLocation(); diff --git a/src/main/java/org/rf/rfserver/party/service/PartyService.java b/src/main/java/org/rf/rfserver/party/service/PartyService.java index 664d448d..255eb98c 100644 --- a/src/main/java/org/rf/rfserver/party/service/PartyService.java +++ b/src/main/java/org/rf/rfserver/party/service/PartyService.java @@ -89,7 +89,7 @@ public PostPartyRes createParty(PostPartyReq postPartyReq, MultipartFile file) t } } - public void addOwnerToParty(User user, Party party) { + public void addOwnerToParty(User user, Party party) throws BaseException { makeUserParty(user, party); if (userService.isKorean(user)) { party.plusCurrentNativeCount(); @@ -200,11 +200,11 @@ public boolean isFullParty(Party party) { return false; } - public Boolean isFullOfKorean(Party party) throws BaseException { + public Boolean isFullOfKorean(Party party) { if(party.getNativeCount() <= party.getCurrentNativeCount()) { return true; } - throw new BaseException(FULL_OF_KOREAN); + return false; } public void isJoinedUser(User user, Party party) throws BaseException { @@ -233,7 +233,7 @@ public PostApproveJoinRes approveJoin(Long partyJoinApplicationId) throws BaseEx return new PostApproveJoinRes(partyJoinApplicationId); } - public void makeUserParty(User user, Party party) { + public void makeUserParty(User user, Party party) throws BaseException { UserParty userParty = new UserParty(party, user); userPartyRepository.save(userParty); partyidUseridService.setPartyidUserid(party.getId(), user.getId()); @@ -369,6 +369,8 @@ public PageDto> recommendGroupParties(Long userId, Pag .imageFilePath(party.getImageFilePath()) .memberCount(party.getMemberCount()) .ownerId(party.getOwnerId()) + .interests(party.getInterests()) + .currentMemberCount(party.getUsers().size()) .build()) .collect(Collectors.toList())); } @@ -433,6 +435,8 @@ public PageDto> recommendPersonalParties(Long userId, .imageFilePath(party.getImageFilePath()) .memberCount(party.getMemberCount()) .ownerId(party.getOwnerId()) + .interests(party.getInterests()) + .currentMemberCount(party.getUsers().size()) .build()) .collect(Collectors.toList())); } diff --git a/src/main/java/org/rf/rfserver/redisDomain/partyidUserid/repository/PartyidUseridRepository.java b/src/main/java/org/rf/rfserver/redisDomain/partyidUserid/repository/PartyidUseridRepository.java index 3a4326a0..744f4efb 100644 --- a/src/main/java/org/rf/rfserver/redisDomain/partyidUserid/repository/PartyidUseridRepository.java +++ b/src/main/java/org/rf/rfserver/redisDomain/partyidUserid/repository/PartyidUseridRepository.java @@ -2,6 +2,11 @@ import org.rf.rfserver.redisDomain.partyidUserid.PartyidUserid; import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; +import java.util.Optional; + +@Repository public interface PartyidUseridRepository extends CrudRepository { + Optional findByPartyId(Long partyId); } diff --git a/src/main/java/org/rf/rfserver/user/controller/UserController.java b/src/main/java/org/rf/rfserver/user/controller/UserController.java index 48e41a72..a8cfffc1 100644 --- a/src/main/java/org/rf/rfserver/user/controller/UserController.java +++ b/src/main/java/org/rf/rfserver/user/controller/UserController.java @@ -11,10 +11,8 @@ import org.rf.rfserver.user.dto.sign.LoginReq; import org.rf.rfserver.user.dto.sign.LoginRes; import org.rf.rfserver.user.service.UserService; -import org.springframework.http.HttpStatus; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; -import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile;