Skip to content

Commit

Permalink
Merge branch 'main' into feature/#107/fixAndDeletePartyImage
Browse files Browse the repository at this point in the history
  • Loading branch information
lreowy authored Aug 31, 2023
2 parents 4453a14 + 133cb81 commit 5a3a140
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/rf/rfserver/chat/service/ChatPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Long> 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)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/rf/rfserver/constant/Rule.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public enum Rule implements EnumModel{
,NO_SEXUAL("선정적인 이야기 금지")
,POLITE_SPEECH("존댓말로 대화해요")
,INFORMAL_SPEECH("반말로 대화해요")
,ACTIVE_VACATION("방학 떄도 활동할 사람을 원해요")
,ACTIVE_VACATION("방학 때도 활동할 사람을 원해요")
,PURE("건전한 모임 활동을 원해요")
,DAILY_TALK("하루에 한 번 대화는 꼭 참여해요")
,FREE_MOOD("자유로운 분위기를 원해요")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
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) {
deviceTokenRedisRepository.save(new DeviceToken(userId, 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ public class GetInterestPartyRes {
private Integer memberCount;
private Long ownerId;
private List<Interest> interests;

private Integer currentMemberCount;

@Builder
public GetInterestPartyRes(Long id, String name, String content, String imageFilePath,
LocalDateTime createdDate, int memberCount, Long ownerId, List<Interest> interests) {
LocalDateTime createdDate, Integer memberCount, Long ownerId, List<Interest> interests,
Integer currentMemberCount) {
this.id = id;
this.name = name;
this.content = content;
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@AllArgsConstructor
@Getter
public class PostPartyRes {
private Long partyId;
private Long id;
private String name;
private String content;
private String location;
Expand All @@ -27,7 +27,7 @@ public class PostPartyRes {
private List<Interest> 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();
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/org/rf/rfserver/party/service/PartyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -369,6 +369,8 @@ public PageDto<List<GetInterestPartyRes>> recommendGroupParties(Long userId, Pag
.imageFilePath(party.getImageFilePath())
.memberCount(party.getMemberCount())
.ownerId(party.getOwnerId())
.interests(party.getInterests())
.currentMemberCount(party.getUsers().size())
.build())
.collect(Collectors.toList()));
}
Expand Down Expand Up @@ -433,6 +435,8 @@ public PageDto<List<GetInterestPartyRes>> recommendPersonalParties(Long userId,
.imageFilePath(party.getImageFilePath())
.memberCount(party.getMemberCount())
.ownerId(party.getOwnerId())
.interests(party.getInterests())
.currentMemberCount(party.getUsers().size())
.build())
.collect(Collectors.toList()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PartyidUserid, Long> {
Optional<PartyidUserid> findByPartyId(Long partyId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 5a3a140

Please sign in to comment.