feat(chat): DM 채팅 저장소를 추가한다

This commit is contained in:
2026-06-10 18:11:47 +09:00
parent 630f84c3e5
commit a289849a07
2 changed files with 231 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
package kr.co.vividnext.sodalive.v2.main.chat.dm.data
import io.reactivex.rxjava3.core.Single
import kr.co.vividnext.sodalive.common.ApiResponse
class DmChatRepository(private val api: DmChatApi) {
fun createOrGetRoom(
token: String,
creatorId: Long
): Single<ApiResponse<CreateDmChatRoomResponse>> = api.createDmChatRoom(
authHeader = bearer(token),
request = CreateDmChatRoomRequest(creatorId = creatorId)
)
fun openRoom(
token: String,
roomId: Long,
limit: Int = DEFAULT_LIMIT
): Single<ApiResponse<DmChatRoomOpenResponse>> = api.openDmChatRoom(
authHeader = bearer(token),
roomId = roomId,
limit = limit
)
fun getMessages(
token: String,
roomId: Long,
cursor: Long?,
limit: Int = DEFAULT_LIMIT
): Single<ApiResponse<DmChatMessagesPageResponse>> = api.getDmChatMessages(
authHeader = bearer(token),
roomId = roomId,
cursor = cursor,
limit = limit
)
fun sendTextMessage(
token: String,
roomId: Long,
textMessage: String
): Single<ApiResponse<SendDmChatMessageResponse>> = api.sendDmTextMessage(
authHeader = bearer(token),
roomId = roomId,
request = SendDmTextMessageRequest(textMessage = textMessage)
)
fun disconnectRealtime(
token: String,
roomId: Long
): Single<ApiResponse<Boolean>> = api.disconnectRealtime(
authHeader = bearer(token),
roomId = roomId
)
private fun bearer(token: String) = "Bearer $token"
private companion object {
const val DEFAULT_LIMIT = 20
}
}