default to None if "name" in m.room.name
is empty
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
3e902836cc
commit
dda3b0e7e2
1 changed files with 3 additions and 4 deletions
|
@ -230,10 +230,9 @@ impl Service {
|
||||||
|
|
||||||
pub fn get_name(&self, room_id: &RoomId) -> Result<Option<String>> {
|
pub fn get_name(&self, room_id: &RoomId) -> Result<Option<String>> {
|
||||||
services().rooms.state_accessor.room_state_get(room_id, &StateEventType::RoomName, "")?.map_or(Ok(None), |s| {
|
services().rooms.state_accessor.room_state_get(room_id, &StateEventType::RoomName, "")?.map_or(Ok(None), |s| {
|
||||||
serde_json::from_str(s.content.get()).map(|c: RoomNameEventContent| Some(c.name)).map_err(|e| {
|
Ok(serde_json::from_str(s.content.get())
|
||||||
error!("Invalid room name event in database for room {}. {}", room_id, e);
|
.map(|c: RoomNameEventContent| Some(c.name))
|
||||||
Error::bad_database("Invalid room name event in database.")
|
.unwrap_or_else(|_| None))
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue