feat(creator-channel): FanTalk 답글 API 응답을 연결한다

This commit is contained in:
2026-07-09 07:43:47 +09:00
parent f9160ccb02
commit 643fb9fa8e
5 changed files with 38 additions and 7 deletions

View File

@@ -13,6 +13,7 @@ import kr.co.vividnext.sodalive.explorer.profile.channel_donation.PostChannelDon
import kr.co.vividnext.sodalive.explorer.profile.donation.GetDonationAllResponse
import kr.co.vividnext.sodalive.explorer.profile.follow.GetFollowerListResponse
import kr.co.vividnext.sodalive.live.room.detail.GetRoomDetailUser
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.data.CreatorChannelFanTalkReplyResponse
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
@@ -73,13 +74,13 @@ interface ExplorerApi {
fun writeCheers(
@Body request: PostWriteCheersRequest,
@Header("Authorization") authHeader: String
): Single<ApiResponse<Any>>
): Single<ApiResponse<CreatorChannelFanTalkReplyResponse>>
@PUT("/explorer/profile/cheers")
fun modifyCheers(
@Body request: PutModifyCheersRequest,
@Header("Authorization") authHeader: String
): Single<ApiResponse<Any>>
): Single<ApiResponse<CreatorChannelFanTalkReplyResponse>>
@POST("/explorer/profile/channel-donation")
fun postChannelDonation(

View File

@@ -196,4 +196,21 @@ class CreatorChannelRepository(
content = content,
token = token
)
fun writeFanTalkReply(fanTalkId: Long, creatorId: Long, content: String, token: String) = explorerRepository.writeCheers(
parentCheersId = fanTalkId,
creatorId = creatorId,
content = content,
token = token
)
fun modifyFanTalkReply(replyFanTalkId: Long, content: String, token: String) = explorerRepository.modifyCheers(
request = PutModifyCheersRequest(cheersId = replyFanTalkId, content = content),
token = token
)
fun deleteFanTalkReply(replyFanTalkId: Long, token: String) = explorerRepository.modifyCheers(
request = PutModifyCheersRequest(cheersId = replyFanTalkId, isActive = false),
token = token
)
}

View File

@@ -23,11 +23,22 @@ private fun CreatorChannelFanTalkResponse.toFanTalkUiModel(
writerProfileImageUrl = writerProfileImageUrl,
content = content,
createdAtText = relativeTimeTextFormatter.format(createdAtUtc),
reply = creatorReplies.firstOrNull()?.toReplyUiModel(relativeTimeTextFormatter),
reply = creatorReplies.orEmpty().firstOrNull()?.toFanTalkReplyUiModel(relativeTimeTextFormatter),
rightAction = toRightAction(isOwner = isOwner, currentUserId = currentUserId)
)
private fun CreatorChannelFanTalkReplyResponse.toReplyUiModel(
fun CreatorChannelFanTalkReplyResponse.toFanTalkReplyUiModel(
relativeTimeTextFormatter: UtcRelativeTimeTextFormatter
) = CreatorChannelFanTalkReplyUiModel(
fanTalkId = fanTalkId,
writerId = writerId,
writerNickname = writerNickname,
writerProfileImageUrl = writerProfileImageUrl,
content = content,
createdAtText = relativeTimeTextFormatter.format(createdAtUtc)
)
fun CreatorChannelFanTalkResponse.toFanTalkReplyUiModel(
relativeTimeTextFormatter: UtcRelativeTimeTextFormatter
) = CreatorChannelFanTalkReplyUiModel(
fanTalkId = fanTalkId,

View File

@@ -16,6 +16,7 @@ import kr.co.vividnext.sodalive.common.ApiResponse
import kr.co.vividnext.sodalive.common.AndroidUtcRelativeTimeTextFormatter
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelRepository
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.data.CreatorChannelFanTalkReplyResponse
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.data.CreatorChannelFanTalkResponse
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.data.CreatorChannelFanTalkTabResponse
import org.junit.After
@@ -104,7 +105,7 @@ class CreatorChannelFanTalkActionTest {
Single.just(ApiResponse(true, fanTalkResponse(ids = listOf(2L)), null))
)
whenever(repository.deleteFanTalk(1L, "Bearer test-token"))
.thenReturn(Single.just(ApiResponse(true, Any(), "deleted")))
.thenReturn(Single.just(ApiResponse<CreatorChannelFanTalkReplyResponse>(true, null, "deleted")))
viewModel.loadFanTalks(100L, isOwner = false)
viewModel.deleteFanTalk(1L)

View File

@@ -13,6 +13,7 @@ import io.reactivex.rxjava3.schedulers.Schedulers
import kr.co.vividnext.sodalive.common.ApiResponse
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
import kr.co.vividnext.sodalive.v2.creator.channel.data.CreatorChannelRepository
import kr.co.vividnext.sodalive.v2.creator.channel.fantalk.data.CreatorChannelFanTalkReplyResponse
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
@@ -106,7 +107,7 @@ class CreatorChannelFanTalkWriteViewModelTest {
@Test
fun `활성 상태에서 submit하면 trim content와 토큰으로 FanTalk 등록 API를 호출한다`() {
whenever(repository.writeFanTalk(100L, "응원합니다", "Bearer test-token"))
.thenReturn(Single.just(ApiResponse<Any>(true, null, null)))
.thenReturn(Single.just(ApiResponse<CreatorChannelFanTalkReplyResponse>(true, null, null)))
viewModel.onContentChanged(" 응원합니다 ")
viewModel.submit(creatorId = 100L)
@@ -132,7 +133,7 @@ class CreatorChannelFanTalkWriteViewModelTest {
@Test
fun `등록 실패 시 입력값을 유지하고 서버 message를 우선 toast로 emit한다`() {
whenever(repository.writeFanTalk(100L, "응원합니다", "Bearer test-token"))
.thenReturn(Single.just(ApiResponse<Any>(false, null, "서버 실패")))
.thenReturn(Single.just(ApiResponse<CreatorChannelFanTalkReplyResponse>(false, null, "서버 실패")))
viewModel.onContentChanged(" 응원합니다 ")
viewModel.submit(creatorId = 100L)