mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-19 18:13:41 -05:00
web/timeline: add validation for per-message profiles
This commit is contained in:
parent
9e63da1b6b
commit
f94d84b044
2 changed files with 10 additions and 2 deletions
|
@ -118,5 +118,13 @@ export function getPerMessageProfile(evt: MemDBEvent | null): BeeperPerMessagePr
|
|||
if (evt === null || evt.type !== "m.room.message" && evt.type !== "m.sticker") {
|
||||
return undefined
|
||||
}
|
||||
return (evt.content as MessageEventContent)["com.beeper.per_message_profile"]
|
||||
const profile = (evt.content as MessageEventContent)["com.beeper.per_message_profile"]
|
||||
if (profile?.displayname && typeof profile.displayname !== "string") {
|
||||
return undefined
|
||||
} else if (profile?.avatar_url && typeof profile.avatar_url !== "string") {
|
||||
return undefined
|
||||
} else if (profile?.id && typeof profile.id !== "string") {
|
||||
return undefined
|
||||
}
|
||||
return profile
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ export function getServerName(userID: UserID): string {
|
|||
}
|
||||
|
||||
export function getDisplayname(userID: UserID, profile?: UserProfile | null): string {
|
||||
return profile?.displayname || getLocalpart(userID)
|
||||
return ensureString(profile?.displayname) || getLocalpart(userID)
|
||||
}
|
||||
|
||||
export function parseMXC(mxc: unknown): [string, string] | [] {
|
||||
|
|
Loading…
Add table
Reference in a new issue