feat: show room avatar when is DM
This commit is contained in:
@@ -25,6 +25,7 @@ import splitties.init.appCtx
|
||||
import splitties.preferences.edit
|
||||
|
||||
data class Me (val userId: String, val deviceId: String)
|
||||
data class UserProfile (val displayName: String, val avatarUrl: String, val other: JSONObject)
|
||||
|
||||
/**
|
||||
* This func is to validate the token
|
||||
@@ -82,3 +83,18 @@ suspend fun login(server: String, login: String, pass: String): Boolean {
|
||||
|
||||
return initCheck()
|
||||
}
|
||||
|
||||
suspend fun getAccountData(user: String, state: String): JSONObject? {
|
||||
val r = client.get("$baseUrl/user/$user/account_data/$state") { bearerAuth(token) }
|
||||
if (r.status != HttpStatusCode.OK) return null
|
||||
return JSONObject(r.bodyAsText())
|
||||
}
|
||||
|
||||
suspend fun getUserProfile(userId: String): UserProfile? {
|
||||
val r = client.get("$baseUrl/profile/$userId") { bearerAuth(token) }
|
||||
if (r.status != HttpStatusCode.OK) return null
|
||||
val json = JSONObject(r.bodyAsText())
|
||||
val name = json.optString("displayname", ""); json.remove("displayname")
|
||||
val avatar = json.optString("avatar_url", ""); json.remove("avatar_url")
|
||||
return UserProfile(name, avatar, json)
|
||||
}
|
||||
Reference in New Issue
Block a user