feat: show room avatar when is DM

This commit is contained in:
2025-11-04 16:01:14 +03:00
parent 5897d31a51
commit 05fbfbac07
6 changed files with 98 additions and 44 deletions
@@ -1,7 +1,6 @@
/*
* Created by sweetbread
* Copyright (c) 2025. All rights reserved.
* Last modified 03.03.2025, 15:40
*/
package ru.risdeveau.pixeldragon.api
@@ -28,9 +27,11 @@ suspend fun getHomeserver(url: String): String? {
return homeserver
}
fun mxcToUrl(mxc: String): String {
val pattern = Regex("mxc://([-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6})/([a-zA-Z]+)")
fun mxcToUrl(mxc: String): String? {
val pattern = Regex("mxc://([-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6})/([a-zA-Z0-9]+)")
val match = pattern.find(mxc)
if ((match?.groupValues[1] == null) or (match?.groupValues[2] == null)) return null
return "$homeserver/_matrix/client/v1/media/download/${match?.groupValues[1]}/${match?.groupValues[2]}"
}