From dda3b0e7e2a89da89c6ddd18478d0c101832a82b Mon Sep 17 00:00:00 2001 From: strawberry Date: Wed, 20 Mar 2024 17:43:48 -0400 Subject: [PATCH] default to None if "name" in `m.room.name` is empty Signed-off-by: strawberry --- src/service/rooms/state_accessor/mod.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/service/rooms/state_accessor/mod.rs b/src/service/rooms/state_accessor/mod.rs index 84fc3a28..1ada031e 100644 --- a/src/service/rooms/state_accessor/mod.rs +++ b/src/service/rooms/state_accessor/mod.rs @@ -230,10 +230,9 @@ impl Service { pub fn get_name(&self, room_id: &RoomId) -> Result> { 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)) }) }