wip: Room list
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Created by sweetbread on 21.02.2025, 12:01
|
||||
* Created by sweetbread on 22.02.2025, 17:28
|
||||
* Copyright (c) 2025. All rights reserved.
|
||||
* Last modified 21.02.2025, 12:01
|
||||
* Last modified 22.02.2025, 17:28
|
||||
*/
|
||||
|
||||
package ru.risdeveau.pixeldragon.api
|
||||
@@ -11,6 +11,7 @@ import io.ktor.client.statement.bodyAsText
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import ru.risdeveau.pixeldragon.client
|
||||
import ru.risdeveau.pixeldragon.homeserver
|
||||
|
||||
suspend fun isMatrixServer(url: String): Boolean {
|
||||
val r = try { client.get("https://$url/.well-known/matrix/client") }
|
||||
@@ -20,4 +21,11 @@ suspend fun isMatrixServer(url: String): Boolean {
|
||||
catch (_: JSONException) { return false }
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
fun mxcToUrl(mxc: String): String {
|
||||
val pattern = Regex("mxc://([-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6})/([a-zA-Z]+)")
|
||||
val match = pattern.find(mxc)
|
||||
|
||||
return "https://$homeserver/_matrix/client/v1/media/download/${match?.groupValues[1]}/${match?.groupValues[2]}"
|
||||
}
|
||||
Reference in New Issue
Block a user