ignore read receipts from ACL'd servers and users not joined
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
003d4edbfa
commit
b8ec763a7c
1 changed files with 46 additions and 31 deletions
|
@ -327,40 +327,55 @@ pub(crate) async fn send_transaction_message_route(
|
||||||
|
|
||||||
for (room_id, room_updates) in receipt.receipts {
|
for (room_id, room_updates) in receipt.receipts {
|
||||||
for (user_id, user_updates) in room_updates.read {
|
for (user_id, user_updates) in room_updates.read {
|
||||||
if let Some((event_id, _)) = user_updates
|
if services()
|
||||||
.event_ids
|
.rooms
|
||||||
.iter()
|
.event_handler
|
||||||
.filter_map(|id| {
|
.acl_check(user_id.server_name(), &room_id)
|
||||||
|
.is_err()
|
||||||
|
{
|
||||||
|
debug_warn!(%user_id, %room_id, "received read receipt EDU from ACL'd user's server");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if services().rooms.state_cache.is_joined(&user_id, &room_id)? {
|
||||||
|
if let Some((event_id, _)) = user_updates
|
||||||
|
.event_ids
|
||||||
|
.iter()
|
||||||
|
.filter_map(|id| {
|
||||||
|
services()
|
||||||
|
.rooms
|
||||||
|
.timeline
|
||||||
|
.get_pdu_count(id)
|
||||||
|
.ok()
|
||||||
|
.flatten()
|
||||||
|
.map(|r| (id, r))
|
||||||
|
})
|
||||||
|
.max_by_key(|(_, count)| *count)
|
||||||
|
{
|
||||||
|
let mut user_receipts = BTreeMap::new();
|
||||||
|
user_receipts.insert(user_id.clone(), user_updates.data);
|
||||||
|
|
||||||
|
let mut receipts = BTreeMap::new();
|
||||||
|
receipts.insert(ReceiptType::Read, user_receipts);
|
||||||
|
|
||||||
|
let mut receipt_content = BTreeMap::new();
|
||||||
|
receipt_content.insert(event_id.to_owned(), receipts);
|
||||||
|
|
||||||
|
let event = ReceiptEvent {
|
||||||
|
content: ReceiptEventContent(receipt_content),
|
||||||
|
room_id: room_id.clone(),
|
||||||
|
};
|
||||||
services()
|
services()
|
||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.read_receipt
|
||||||
.get_pdu_count(id)
|
.readreceipt_update(&user_id, &room_id, event)?;
|
||||||
.ok()
|
} else {
|
||||||
.flatten()
|
// TODO fetch missing events
|
||||||
.map(|r| (id, r))
|
debug_error!("No known event ids in read receipt: {:?}", user_updates);
|
||||||
})
|
}
|
||||||
.max_by_key(|(_, count)| *count)
|
|
||||||
{
|
|
||||||
let mut user_receipts = BTreeMap::new();
|
|
||||||
user_receipts.insert(user_id.clone(), user_updates.data);
|
|
||||||
|
|
||||||
let mut receipts = BTreeMap::new();
|
|
||||||
receipts.insert(ReceiptType::Read, user_receipts);
|
|
||||||
|
|
||||||
let mut receipt_content = BTreeMap::new();
|
|
||||||
receipt_content.insert(event_id.to_owned(), receipts);
|
|
||||||
|
|
||||||
let event = ReceiptEvent {
|
|
||||||
content: ReceiptEventContent(receipt_content),
|
|
||||||
room_id: room_id.clone(),
|
|
||||||
};
|
|
||||||
services()
|
|
||||||
.rooms
|
|
||||||
.read_receipt
|
|
||||||
.readreceipt_update(&user_id, &room_id, event)?;
|
|
||||||
} else {
|
} else {
|
||||||
// TODO fetch missing events
|
debug_warn!(%user_id, %room_id, "received read receipt EDU for user not in room");
|
||||||
debug_error!("No known event ids in read receipt: {:?}", user_updates);
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue