default to None if "name" in m.room.name is empty

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-03-20 17:43:48 -04:00 committed by June
parent 3e902836cc
commit dda3b0e7e2

View file

@ -230,10 +230,9 @@ impl Service {
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| {
serde_json::from_str(s.content.get()).map(|c: RoomNameEventContent| Some(c.name)).map_err(|e| {
error!("Invalid room name event in database for room {}. {}", room_id, e);
Error::bad_database("Invalid room name event in database.")
})
Ok(serde_json::from_str(s.content.get())
.map(|c: RoomNameEventContent| Some(c.name))
.unwrap_or_else(|_| None))
})
}