Return NotFound for empty room name string.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -30,6 +30,7 @@ use ruma::{
|
|||||||
use tuwunel_core::{
|
use tuwunel_core::{
|
||||||
Result, err, is_true,
|
Result, err, is_true,
|
||||||
matrix::{Pdu, room_version, state_res::events::RoomCreateEvent},
|
matrix::{Pdu, room_version, state_res::events::RoomCreateEvent},
|
||||||
|
utils::BoolExt,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Service {
|
pub struct Service {
|
||||||
@@ -74,7 +75,13 @@ impl Service {
|
|||||||
pub async fn get_name(&self, room_id: &RoomId) -> Result<String> {
|
pub async fn get_name(&self, room_id: &RoomId) -> Result<String> {
|
||||||
self.room_state_get_content(room_id, &StateEventType::RoomName, "")
|
self.room_state_get_content(room_id, &StateEventType::RoomName, "")
|
||||||
.await
|
.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<RoomAvatarEventContent> {
|
pub async fn get_avatar(&self, room_id: &RoomId) -> Result<RoomAvatarEventContent> {
|
||||||
|
|||||||
Reference in New Issue
Block a user