mirror of
https://github.com/maubot/maubot.git
synced 2024-10-01 01:06:10 -04:00
Fix avatar URLs without mxc:// looking like they work when they actually don't. Fixes #85
This commit is contained in:
parent
ae7e9693fc
commit
3585ed9456
@ -214,10 +214,10 @@ export async function uploadAvatar(id, data, mime) {
|
||||
}
|
||||
|
||||
export function getAvatarURL({ id, avatar_url }) {
|
||||
avatar_url = avatar_url || ""
|
||||
if (avatar_url.startsWith("mxc://")) {
|
||||
avatar_url = avatar_url.substr("mxc://".length)
|
||||
if (!avatar_url?.startsWith("mxc://")) {
|
||||
return null
|
||||
}
|
||||
avatar_url = avatar_url.substr("mxc://".length)
|
||||
return `${BASE_PATH}/proxy/${id}/_matrix/media/r0/download/${avatar_url}?access_token=${
|
||||
localStorage.accessToken}`
|
||||
}
|
||||
|
@ -215,8 +215,12 @@ class Client extends BaseMainView {
|
||||
}
|
||||
|
||||
get avatarMXC() {
|
||||
return this.state.avatar_url === "disable"
|
||||
? this.props.entry.remote_avatar_url : this.state.avatar_url
|
||||
if (this.state.avatar_url === "disable") {
|
||||
return this.props.entry.remote_avatar_url
|
||||
} else if (!this.state.avatar_url?.startsWith("mxc://")) {
|
||||
return null
|
||||
}
|
||||
return this.state.avatar_url
|
||||
}
|
||||
|
||||
get avatarURL() {
|
||||
|
Loading…
Reference in New Issue
Block a user