Skip to content

Commit

Permalink
accept receipts prior to events
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Volk <[email protected]>
  • Loading branch information
jevolk committed Jun 2, 2024
1 parent b16fd66 commit 69958a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extern crate conduit_core as conduit;
extern crate conduit_service as service;

pub use client_server::membership::{join_room_by_id_helper, leave_all_rooms};
pub(crate) use conduit::{debug_error, debug_info, debug_warn, utils, Error, Result};
pub(crate) use conduit::{debug_info, debug_warn, utils, Error, Result};
pub(crate) use ruma_wrapper::{Ruma, RumaResponse};
pub(crate) use service::{pdu::PduEvent, services, user_is_local};

Expand Down
22 changes: 3 additions & 19 deletions src/api/server_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ use tracing::{debug, error, trace, warn};

use crate::{
client_server::{self, claim_keys_helper, get_keys_helper},
debug_error,
service::{
pdu::{gen_event_id_canonical_json, PduBuilder},
rooms::event_handler::parse_incoming_pdu,
Expand Down Expand Up @@ -369,22 +368,9 @@ pub(crate) async fn send_transaction_message_route(
}

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)
{
for event_id in &user_updates.event_ids {
let mut user_receipts = BTreeMap::new();
user_receipts.insert(user_id.clone(), user_updates.data);
user_receipts.insert(user_id.clone(), user_updates.data.clone());

let mut receipts = BTreeMap::new();
receipts.insert(ReceiptType::Read, user_receipts);
Expand All @@ -396,13 +382,11 @@ pub(crate) async fn send_transaction_message_route(
content: ReceiptEventContent(receipt_content),
room_id: room_id.clone(),
};

services()
.rooms
.read_receipt
.readreceipt_update(&user_id, &room_id, event)?;
} else {
// TODO fetch missing events
debug_error!("No known event ids in read receipt: {:?}", user_updates);
}
} else {
debug_warn!(%user_id, %room_id, "received read receipt EDU for user not in room");
Expand Down

0 comments on commit 69958a4

Please sign in to comment.