default to shared room history visibility if invalid (per spec)
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
eebdd30ed7
commit
c5c8934db7
3 changed files with 37 additions and 13 deletions
|
@ -254,8 +254,8 @@ pub(crate) async fn get_public_rooms_filtered_helper(
|
|||
.map_or(Ok(None), |s| {
|
||||
serde_json::from_str(s.content.get())
|
||||
.map(|c: RoomTopicEventContent| Some(c.topic))
|
||||
.map_err(|_| {
|
||||
error!("Invalid room topic event in database for room {}", room_id);
|
||||
.map_err(|e| {
|
||||
error!("Invalid room topic event in database for room {room_id}: {e}");
|
||||
Error::bad_database("Invalid room topic event in database.")
|
||||
})
|
||||
})
|
||||
|
@ -271,11 +271,10 @@ pub(crate) async fn get_public_rooms_filtered_helper(
|
|||
})
|
||||
.map_err(|e| {
|
||||
error!(
|
||||
"Invalid room history visibility event in database for room {}: {e}",
|
||||
&room_id
|
||||
"Invalid room history visibility event in database for room {room_id}, assuming is \"shared\": {e}",
|
||||
);
|
||||
Error::bad_database("Invalid room history visibility event in database.")
|
||||
})})?,
|
||||
})}).unwrap_or(false),
|
||||
guest_can_join: services()
|
||||
.rooms
|
||||
.state_accessor
|
||||
|
|
|
@ -832,15 +832,22 @@ fn guest_can_join(room_id: &RoomId) -> Result<bool, Error> {
|
|||
|
||||
/// Checks if guests are able to view room content without joining
|
||||
fn world_readable(room_id: &RoomId) -> Result<bool, Error> {
|
||||
services()
|
||||
Ok(services()
|
||||
.rooms
|
||||
.state_accessor
|
||||
.room_state_get(room_id, &StateEventType::RoomHistoryVisibility, "")?
|
||||
.map_or(Ok(false), |s| {
|
||||
serde_json::from_str(s.content.get())
|
||||
.map(|c: RoomHistoryVisibilityEventContent| c.history_visibility == HistoryVisibility::WorldReadable)
|
||||
.map_err(|_| Error::bad_database("Invalid room history visibility event in database."))
|
||||
.map_err(|e| {
|
||||
error!(
|
||||
"Invalid room history visibility event in database for room {room_id}, assuming is \
|
||||
\"shared\": {e} "
|
||||
);
|
||||
Error::bad_database("Invalid room history visibility event in database.")
|
||||
})
|
||||
})
|
||||
.unwrap_or(false))
|
||||
}
|
||||
|
||||
/// Returns the join rule for a given room
|
||||
|
|
|
@ -107,8 +107,15 @@ impl Service {
|
|||
.map_or(Ok(HistoryVisibility::Shared), |s| {
|
||||
serde_json::from_str(s.content.get())
|
||||
.map(|c: RoomHistoryVisibilityEventContent| c.history_visibility)
|
||||
.map_err(|_| Error::bad_database("Invalid history visibility event in database."))
|
||||
})?;
|
||||
.map_err(|e| {
|
||||
error!(
|
||||
"Invalid history visibility event in database for room {room_id}, assuming is \"shared\": \
|
||||
{e}"
|
||||
);
|
||||
Error::bad_database("Invalid history visibility event in database.")
|
||||
})
|
||||
})
|
||||
.unwrap_or(HistoryVisibility::Shared);
|
||||
|
||||
let mut current_server_members = services()
|
||||
.rooms
|
||||
|
@ -165,8 +172,15 @@ impl Service {
|
|||
.map_or(Ok(HistoryVisibility::Shared), |s| {
|
||||
serde_json::from_str(s.content.get())
|
||||
.map(|c: RoomHistoryVisibilityEventContent| c.history_visibility)
|
||||
.map_err(|_| Error::bad_database("Invalid history visibility event in database."))
|
||||
})?;
|
||||
.map_err(|e| {
|
||||
error!(
|
||||
"Invalid history visibility event in database for room {room_id}, assuming is \"shared\": \
|
||||
{e}"
|
||||
);
|
||||
Error::bad_database("Invalid history visibility event in database.")
|
||||
})
|
||||
})
|
||||
.unwrap_or(HistoryVisibility::Shared);
|
||||
|
||||
let visibility = match history_visibility {
|
||||
HistoryVisibility::WorldReadable => true,
|
||||
|
@ -205,10 +219,14 @@ impl Service {
|
|||
serde_json::from_str(s.content.get())
|
||||
.map(|c: RoomHistoryVisibilityEventContent| c.history_visibility)
|
||||
.map_err(|e| {
|
||||
error!("Invalid history visibility event in database for room {}: {e}", &room_id);
|
||||
error!(
|
||||
"Invalid history visibility event in database for room {room_id}, assuming is \"shared\": \
|
||||
{e}"
|
||||
);
|
||||
Error::bad_database("Invalid history visibility event in database.")
|
||||
})
|
||||
})?;
|
||||
})
|
||||
.unwrap_or(HistoryVisibility::Shared);
|
||||
|
||||
Ok(currently_member || history_visibility == HistoryVisibility::WorldReadable)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue