mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
drop redacted events from search results
This commit is contained in:
parent
f74043df9a
commit
83cdc9c708
2 changed files with 28 additions and 9 deletions
|
|
@ -101,15 +101,16 @@ pub(crate) async fn search_events_route(
|
||||||
.get_pdu_from_id(result)
|
.get_pdu_from_id(result)
|
||||||
.ok()?
|
.ok()?
|
||||||
.filter(|pdu| {
|
.filter(|pdu| {
|
||||||
services()
|
!pdu.is_redacted()
|
||||||
.rooms
|
&& services()
|
||||||
.state_accessor
|
.rooms
|
||||||
.user_can_see_event(
|
.state_accessor
|
||||||
sender_user,
|
.user_can_see_event(
|
||||||
&pdu.room_id,
|
sender_user,
|
||||||
&pdu.event_id,
|
&pdu.room_id,
|
||||||
)
|
&pdu.event_id,
|
||||||
.unwrap_or(false)
|
)
|
||||||
|
.unwrap_or(false)
|
||||||
})
|
})
|
||||||
.map(|pdu| pdu.to_room_event())
|
.map(|pdu| pdu.to_room_event())
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,24 @@ impl PduEvent {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn is_redacted(&self) -> bool {
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct ExtractRedactedBecause {
|
||||||
|
redacted_because: Option<serde::de::IgnoredAny>,
|
||||||
|
}
|
||||||
|
|
||||||
|
let Some(unsigned) = &self.unsigned else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
let Ok(unsigned) = ExtractRedactedBecause::deserialize(&**unsigned)
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned.redacted_because.is_some()
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn remove_transaction_id(&mut self) -> crate::Result<()> {
|
pub(crate) fn remove_transaction_id(&mut self) -> crate::Result<()> {
|
||||||
if let Some(unsigned) = &self.unsigned {
|
if let Some(unsigned) = &self.unsigned {
|
||||||
let mut unsigned: BTreeMap<String, Box<RawJsonValue>> =
|
let mut unsigned: BTreeMap<String, Box<RawJsonValue>> =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue