Limita una diretta attiva per account e valorizza la copertina Premium Full.

Blocca la seconda diretta sullo stesso utente, registra gli abusi in admin e presenta la copertina come grafica caricata dalla società, con demo Team MLTV.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-01 12:52:26 +02:00
co-authored by Cursor
parent 356aa28fad
commit d52434fb2e
62 changed files with 1509 additions and 109 deletions
@@ -14,6 +14,8 @@ import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import kotlinx.coroutines.delay
import retrofit2.HttpException
class SessionApiException(message: String, cause: Throwable) : Exception(message, cause)
class SessionRepository(
private val api: MatchLiveApi,
private val appContext: Context,
@@ -54,17 +56,15 @@ class SessionRepository(
}
}
private fun parseErrorCode(error: HttpException): String? {
val body = error.response()?.errorBody()?.string().orEmpty()
if (body.isBlank()) return null
return runCatching { errorAdapter.fromJson(body)?.errorCode }.getOrNull()
}
suspend fun fetchSession(sessionId: String): StreamSession =
api.session(sessionId).toDomain()
suspend fun startSession(sessionId: String): StreamSession =
api.startSession(sessionId).toDomain()
try {
api.startSession(sessionId).toDomain()
} catch (e: HttpException) {
throw SessionApiException(parseErrorMessage(e), e)
}
suspend fun stopSession(sessionId: String): StreamSession =
api.stopSession(sessionId).toDomain()
@@ -73,7 +73,11 @@ class SessionRepository(
api.pauseSession(sessionId).toDomain()
suspend fun resumeSession(sessionId: String): StreamSession =
api.resumeSession(sessionId).toDomain()
try {
api.resumeSession(sessionId).toDomain()
} catch (e: HttpException) {
throw SessionApiException(parseErrorMessage(e), e)
}
suspend fun setAudioMute(sessionId: String, muted: Boolean): StreamSession =
api.setAudioMute(sessionId, com.matchlivetv.match_live_tv.data.api.AudioMuteRequest(muted)).toDomain()
@@ -121,4 +125,19 @@ class SessionRepository(
),
)
}
private fun parseErrorCode(error: HttpException): String? {
return parseError(error)?.errorCode
}
private fun parseErrorMessage(error: HttpException): String {
val parsed = parseError(error)
return parsed?.error?.takeIf { it.isNotBlank() } ?: error.message() ?: "HTTP ${error.code()}"
}
private fun parseError(error: HttpException): ApiErrorResponse? {
val body = error.response()?.errorBody()?.string().orEmpty()
if (body.isBlank()) return null
return runCatching { errorAdapter.fromJson(body) }.getOrNull()
}
}