Приложение

This commit is contained in:
Халимов Рустам
2026-04-14 01:15:54 +03:00
parent 8399d32490
commit 1fb1be47dd
126 changed files with 6145 additions and 0 deletions
@@ -0,0 +1,10 @@
package chats.domain.model
data class Chat(
val id: String,
val type: String,
val name: String,
val avatar: String?,
val unreadCount: Int,
val lastMessage: Message?
)
@@ -0,0 +1,21 @@
package chats.domain.model
data class Message(
val id: String,
val chatId: String,
val senderId: String,
val senderName: String,
val content: String?,
val sequenceId: Int,
val createdAt: String,
val media: List<String> = emptyList(),
val mediaUrl: String? = null,
val mediaType: MediaType = MediaType.TEXT,
val reactions: Map<String, Int> = emptyMap(),
val isRead: Boolean = false,
val replyTo: Message? = null
)
enum class MediaType {
TEXT, IMAGE, VIDEO, AUDIO, FILE, STORY_REPLY
}
@@ -0,0 +1,13 @@
package chats.domain.repository
import chats.domain.model.Chat
import chats.domain.model.Message
interface ChatRepository {
suspend fun getChats(): List<Chat>
suspend fun getMessages(chatId: String): List<Message>
suspend fun sendMessage(chatId: String, content: String): Message
suspend fun addReaction(messageId: String, emoji: String)
suspend fun sendTypingStatus(chatId: String)
suspend fun markMessagesAsRead(chatId: String, lastMessageId: String)
}
@@ -0,0 +1,24 @@
package chats.domain.usecase
import chats.data.remote.api.ChatApi
import chats.data.remote.api.FileUploadResponse
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.MultipartBody
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File
import javax.inject.Inject
class UploadMediaUseCase @Inject constructor(
private val api: ChatApi
) {
suspend operator fun invoke(file: File): Result<FileUploadResponse> {
return try {
val requestFile = file.asRequestBody("image/*".toMediaTypeOrNull())
val body = MultipartBody.Part.createFormData("file", file.name, requestFile)
val response = api.uploadFile(body)
Result.success(response)
} catch (e: Exception) {
Result.failure(e)
}
}
}