package ru.forbion.f7cloud.feature.talk

import ru.forbion.f7cloud.core.auth.AuthSession
import java.net.URLEncoder

object TalkUrls {
    fun roomAvatar(session: AuthSession, token: String): String {
        val base = session.serverUrl.trimEnd('/')
        return "$base/ocs/v2.php/apps/spreed/api/v1/room/$token/avatar"
    }

    fun userAvatar(session: AuthSession, userId: String, size: Int = 64): String {
        val base = session.serverUrl.trimEnd('/')
        val encoded = URLEncoder.encode(userId, Charsets.UTF_8.name())
        return "$base/index.php/avatar/$encoded/$size"
    }

    fun filePreview(session: AuthSession, fileId: String, size: Int = 512): String {
        val base = session.serverUrl.trimEnd('/')
        return "$base/index.php/core/preview?fileId=$fileId&x=$size&y=$size&a=1&mode=cover&forceIcon=0"
    }
}
