base: Add a method to get either the display name or the localpart of an user

master
Damir Jelić 2021-01-01 14:59:30 +01:00
parent 0c81f3d9ae
commit b995492457
1 changed files with 8 additions and 0 deletions

View File

@ -47,6 +47,14 @@ impl RoomMember {
}
}
pub fn name(&self) -> &str {
if let Some(d) = self.display_name() {
d
} else {
self.user_id().localpart()
}
}
pub fn normalized_power_level(&self) -> i64 {
if self.max_power_level > 0 {
(self.power_level() * 100) / self.max_power_level