Skip to content

Commit

Permalink
✅ 버킷리스트 작성자, 쪽지 수신인 일치시키지
Browse files Browse the repository at this point in the history
  • Loading branch information
tjdals4716 committed Oct 31, 2024
1 parent 934306f commit fea92cf
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public MessageDTO createMessage(String uid, Long bucketListId, MessageDTO messag
UserEntity sender = userRepository.findByUid(uid);
UserEntity receiver = userRepository.findById(messageDTO.getReceiverId()).orElseThrow();
BucketlistEntity bucketList = bucketRepository.findById(bucketListId).orElseThrow();
if (!bucketList.getUser().getUid().equals(receiver.getUid())) {
throw new RuntimeException("해당 버킷리스트의 생성자에게만 쪽지를 보낼 수 있습니다.");
}
MessageEntity messageEntity = messageDTO.dtoToEntity(sender, receiver, bucketList);
messageEntity.setCreateTime(LocalDateTime.now());
messageEntity.setStatus(MessageStatus.안읽음);
Expand All @@ -51,6 +54,9 @@ public MessageDTO replyMessage(Long messageId, String uid, Long bucketListId, Me
UserEntity sender = userRepository.findByUid(uid);
UserEntity receiver = originalMessage.getSender();
BucketlistEntity bucketList = bucketRepository.findById(bucketListId).orElseThrow();
if (!bucketList.getUser().getUid().equals(receiver.getUid())) {
throw new RuntimeException("해당 버킷리스트의 생성자에게만 쪽지를 답장할 수 있습니다.");
}
MessageEntity messageEntity = messageDTO.dtoToEntity(sender, receiver, bucketList);
messageEntity.setCreateTime(LocalDateTime.now());
messageEntity.setStatus(MessageStatus.안읽음);
Expand Down

0 comments on commit fea92cf

Please sign in to comment.