Skip to content

Commit

Permalink
Feat(Chat) : 메시지 Content 타입 분리
Browse files Browse the repository at this point in the history
- 기존 문자열만 가능한 상태에서 Card, Text 두 타입이 모두 가능하도록 수정
  • Loading branch information
waterfogSW committed Dec 27, 2024
1 parent 44a8142 commit 08d4e9c
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data class ChatMessage(
override val id: Id,
val chatRoomId: ChatRoom.Id,
val senderId: ChatMember.Id,
val content: String,
val content: Content,
val status: Status = Status.SENT,
val createdAt: LocalDateTime = LocalDateTime.now(),
val updatedAt: LocalDateTime? = null,
Expand All @@ -18,6 +18,18 @@ data class ChatMessage(

data class Id(override val value: UUID) : TypeId<UUID>(value)

sealed class Content {
data class Text(val text: String) : Content()
data class Card(
val text: String,
val color: Color
) : Content() {

enum class Color {
BLUE, PINK,
}
}
}

enum class Status {
SENT,
Expand All @@ -40,14 +52,12 @@ data class ChatMessage(
)
}


fun markAsFailed(reason: FailureReason) {
fun markAsFailed(reason: FailureReason): ChatMessage {
require(status == Status.SENT) { "전송된 상태의 메시지만 실패 처리가 가능합니다" }
this.copy(
return this.copy(
status = Status.FAILED,
updatedAt = LocalDateTime.now(),
failureReason = reason
)
}

}

0 comments on commit 08d4e9c

Please sign in to comment.