diff --git a/src/service/rooms/state_accessor/mod.rs b/src/service/rooms/state_accessor/mod.rs index 2f3212ab..d9dfff82 100644 --- a/src/service/rooms/state_accessor/mod.rs +++ b/src/service/rooms/state_accessor/mod.rs @@ -30,6 +30,7 @@ use ruma::{ use tuwunel_core::{ Result, err, is_true, matrix::{Pdu, room_version, state_res::events::RoomCreateEvent}, + utils::BoolExt, }; pub struct Service { @@ -74,7 +75,13 @@ impl Service { pub async fn get_name(&self, room_id: &RoomId) -> Result { self.room_state_get_content(room_id, &StateEventType::RoomName, "") .await - .map(|c: RoomNameEventContent| c.name) + .and_then(|c: RoomNameEventContent| { + c.name + .is_empty() + .is_false() + .then_some(c.name) + .ok_or_else(|| err!(Request(NotFound("Empty name found in event content.")))) + }) } pub async fn get_avatar(&self, room_id: &RoomId) -> Result {