feat: respect history visibility

This commit is contained in:
Timo Kösters 2023-02-22 15:49:55 +01:00
parent 2a16a5e967
commit 10fa686c77
No known key found for this signature in database
GPG key ID: 0B25E636FBA7E4CB
8 changed files with 166 additions and 98 deletions

View file

@ -50,12 +50,12 @@ pub async fn get_context_route(
if !services()
.rooms
.state_cache
.is_joined(sender_user, &room_id)?
.state_accessor
.user_can_see_event(sender_user, &room_id, &body.event_id)?
{
return Err(Error::BadRequest(
ErrorKind::Forbidden,
"You don't have permission to view this room.",
"You don't have permission to view this event.",
));
}
@ -82,6 +82,13 @@ pub async fn get_context_route(
/ 2,
)
.filter_map(|r| r.ok()) // Remove buggy events
.filter(|(_, pdu)| {
services()
.rooms
.state_accessor
.user_can_see_event(sender_user, &room_id, &pdu.event_id)
.unwrap_or(false)
})
.collect();
for (_, event) in &events_before {
@ -114,6 +121,13 @@ pub async fn get_context_route(
/ 2,
)
.filter_map(|r| r.ok()) // Remove buggy events
.filter(|(_, pdu)| {
services()
.rooms
.state_accessor
.user_can_see_event(sender_user, &room_id, &pdu.event_id)
.unwrap_or(false)
})
.collect();
for (_, event) in &events_after {