Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
04b89c1
feat: 207 add individual/group paper type separation
ehddbs4521 Jun 30, 2025
957159e
feat: 207 get rolling paper creator's id from ivitation code
ehddbs4521 Jun 30, 2025
c12f33e
feat: 207 allow anonymous message creation based on paper type
ehddbs4521 Jun 30, 2025
9ffe1cb
test: 207 refactor test
ehddbs4521 Jun 30, 2025
53696c0
choir: 207 delete unused import
ehddbs4521 Jun 30, 2025
b106001
feat: 207 add white list
ehddbs4521 Jun 30, 2025
a729fd0
refactor: 207 delete null option on open date
ehddbs4521 Jun 30, 2025
8d52e73
test: 207 refactor test
ehddbs4521 Jun 30, 2025
e776ae2
feat: 207 get individual message
ehddbs4521 Jun 30, 2025
72308d8
test: 207 add message test
ehddbs4521 Jun 30, 2025
dddfbcd
refactor: 207 delete security requirement on swagger
ehddbs4521 Jul 1, 2025
a239037
Revert "refactor: 207 delete security requirement on swagger"
ehddbs4521 Jul 1, 2025
d35fd46
Revert "test: 207 add message test"
ehddbs4521 Jul 1, 2025
39c7880
Revert "feat: 207 get individual message"
ehddbs4521 Jul 1, 2025
f799aae
Revert "test: 207 refactor test"
ehddbs4521 Jul 1, 2025
88a3ef9
Revert "refactor: 207 delete null option on open date"
ehddbs4521 Jul 1, 2025
0ad1482
Revert "feat: 207 add white list"
ehddbs4521 Jul 1, 2025
1603710
Revert "choir: 207 delete unused import"
ehddbs4521 Jul 1, 2025
0efb170
Revert "test: 207 refactor test"
ehddbs4521 Jul 1, 2025
3f178ab
Revert "feat: 207 allow anonymous message creation based on paper type"
ehddbs4521 Jul 1, 2025
cca0429
Revert "feat: 207 get rolling paper creator's id from ivitation code"
ehddbs4521 Jul 1, 2025
0aee2c9
Revert "feat: 207 add individual/group paper type separation"
ehddbs4521 Jul 1, 2025
82c8ddb
refactor: 211 validate user's message over 5 or not
ehddbs4521 Jul 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ public enum MessageErrorCode implements ErrorCode {
MESSAGE_ACCESS_DENIED(HttpStatus.FORBIDDEN, "M-002", "메시지에 접근할 권한이 없습니다."),

// 409
MESSAGE_ALREADY_EXISTS(HttpStatus.CONFLICT,"M-003", "이미 해당 사용자에게 보낸 메시지가 존재합니다.");
MESSAGE_ALREADY_EXISTS(HttpStatus.CONFLICT, "M-003", "이미 해당 사용자에게 보낸 메시지가 존재합니다."),

// 400
MESSAGE_LIMIT_EXCEEDED(HttpStatus.BAD_REQUEST, "M-004", "메시지는 최대 5개까지만 작성할 수 있습니다."),
;

private HttpStatus httpStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
import doldol_server.doldol.user.entity.User;

public interface MessageRepository extends JpaRepository<Message, Long>, MessageRepositoryCustom {
boolean existsByPaperAndFromAndToAndIsDeletedFalse(Paper paper, User from, User to);
long countByPaperAndFromAndToAndIsDeletedFalse(Paper paper, User fromUser, User toUser);
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,7 @@ public void createMessage(CreateMessageRequest request, Long userId) {
Paper paper = paperRepository.findById(request.paperId())
.orElseThrow(() -> new CustomException(PaperErrorCode.PAPER_NOT_FOUND));

boolean messageExists = messageRepository.existsByPaperAndFromAndToAndIsDeletedFalse(
paper, fromUser, toUser);

if (messageExists) {
throw new CustomException(MessageErrorCode.MESSAGE_ALREADY_EXISTS);
}
validateMessageCount(paper, fromUser, toUser);

paper.addMessage();

Expand Down Expand Up @@ -159,4 +154,12 @@ private MessageResponse decryptMessageContent(MessageResponse messageResponse) {
String decryptedContent = encryptor.decrypt(messageResponse.content());
return messageResponse.withDecryptedContent(decryptedContent);
}

private void validateMessageCount(Paper paper, User fromUser, User toUser) {
long messageCount = messageRepository.countByPaperAndFromAndToAndIsDeletedFalse(
paper, fromUser, toUser);
if (messageCount >= 5) {
throw new CustomException(MessageErrorCode.MESSAGE_LIMIT_EXCEEDED);
}
}
}
Loading