|
|
|
@ -1006,12 +1006,7 @@ pub(crate) async fn handle_incoming_pdu<'a>( |
|
|
|
// 9. Fetch any missing prev events doing all checks listed here starting at 1. These are timeline events
|
|
|
|
// 9. Fetch any missing prev events doing all checks listed here starting at 1. These are timeline events
|
|
|
|
let mut graph = HashMap::new(); |
|
|
|
let mut graph = HashMap::new(); |
|
|
|
let mut eventid_info = HashMap::new(); |
|
|
|
let mut eventid_info = HashMap::new(); |
|
|
|
let mut todo_outlier_stack = incoming_pdu |
|
|
|
let mut todo_outlier_stack = incoming_pdu.prev_events.clone(); |
|
|
|
.prev_events |
|
|
|
|
|
|
|
.iter() |
|
|
|
|
|
|
|
.cloned() |
|
|
|
|
|
|
|
.map(Arc::new) |
|
|
|
|
|
|
|
.collect::<Vec<_>>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut amount = 0; |
|
|
|
let mut amount = 0; |
|
|
|
|
|
|
|
|
|
|
|
@ -1030,7 +1025,7 @@ pub(crate) async fn handle_incoming_pdu<'a>( |
|
|
|
if amount > 100 { |
|
|
|
if amount > 100 { |
|
|
|
// Max limit reached
|
|
|
|
// Max limit reached
|
|
|
|
warn!("Max prev event limit reached!"); |
|
|
|
warn!("Max prev event limit reached!"); |
|
|
|
graph.insert((*prev_event_id).clone(), HashSet::new()); |
|
|
|
graph.insert(prev_event_id.clone(), HashSet::new()); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1047,47 +1042,46 @@ pub(crate) async fn handle_incoming_pdu<'a>( |
|
|
|
amount += 1; |
|
|
|
amount += 1; |
|
|
|
for prev_prev in &pdu.prev_events { |
|
|
|
for prev_prev in &pdu.prev_events { |
|
|
|
if !graph.contains_key(prev_prev) { |
|
|
|
if !graph.contains_key(prev_prev) { |
|
|
|
todo_outlier_stack.push(dbg!(Arc::new(prev_prev.clone()))); |
|
|
|
todo_outlier_stack.push(dbg!(prev_prev.clone())); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
graph.insert( |
|
|
|
graph.insert( |
|
|
|
(*prev_event_id).clone(), |
|
|
|
prev_event_id.clone(), |
|
|
|
pdu.prev_events.iter().cloned().collect(), |
|
|
|
pdu.prev_events.iter().cloned().collect(), |
|
|
|
); |
|
|
|
); |
|
|
|
eventid_info.insert(prev_event_id.clone(), (pdu, json)); |
|
|
|
eventid_info.insert(prev_event_id.clone(), (pdu, json)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Time based check failed
|
|
|
|
// Time based check failed
|
|
|
|
graph.insert((*prev_event_id).clone(), HashSet::new()); |
|
|
|
graph.insert(prev_event_id.clone(), HashSet::new()); |
|
|
|
eventid_info.insert(prev_event_id.clone(), (pdu, json)); |
|
|
|
eventid_info.insert(prev_event_id.clone(), (pdu, json)); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Get json failed
|
|
|
|
// Get json failed
|
|
|
|
graph.insert((*prev_event_id).clone(), HashSet::new()); |
|
|
|
graph.insert(prev_event_id.clone(), HashSet::new()); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Fetch and handle failed
|
|
|
|
// Fetch and handle failed
|
|
|
|
graph.insert((*prev_event_id).clone(), HashSet::new()); |
|
|
|
graph.insert(prev_event_id.clone(), HashSet::new()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let sorted = |
|
|
|
let sorted = state_res::lexicographical_topological_sort(dbg!(&graph), |event_id| { |
|
|
|
state_res::StateResolution::lexicographical_topological_sort(dbg!(&graph), |event_id| { |
|
|
|
// This return value is the key used for sorting events,
|
|
|
|
// This return value is the key used for sorting events,
|
|
|
|
// events are then sorted by power level, time,
|
|
|
|
// events are then sorted by power level, time,
|
|
|
|
// and lexically by event_id.
|
|
|
|
// and lexically by event_id.
|
|
|
|
println!("{}", event_id); |
|
|
|
println!("{}", event_id); |
|
|
|
Ok(( |
|
|
|
Ok(( |
|
|
|
0, |
|
|
|
0, |
|
|
|
MilliSecondsSinceUnixEpoch( |
|
|
|
MilliSecondsSinceUnixEpoch( |
|
|
|
eventid_info |
|
|
|
eventid_info |
|
|
|
.get(event_id) |
|
|
|
.get(event_id) |
|
|
|
.map_or_else(|| uint!(0), |info| info.0.origin_server_ts.clone()), |
|
|
|
.map_or_else(|| uint!(0), |info| info.0.origin_server_ts), |
|
|
|
), |
|
|
|
), |
|
|
|
ruma::event_id!("$notimportant"), |
|
|
|
ruma::event_id!("$notimportant"), |
|
|
|
)) |
|
|
|
)) |
|
|
|
}) |
|
|
|
}) |
|
|
|
.map_err(|_| "Error sorting prev events".to_owned())?; |
|
|
|
.map_err(|_| "Error sorting prev events".to_owned())?; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut errors = 0; |
|
|
|
let mut errors = 0; |
|
|
|
for prev_id in dbg!(sorted) { |
|
|
|
for prev_id in dbg!(sorted) { |
|
|
|
@ -1207,12 +1201,7 @@ fn handle_outlier_pdu<'a>( |
|
|
|
fetch_and_handle_outliers( |
|
|
|
fetch_and_handle_outliers( |
|
|
|
db, |
|
|
|
db, |
|
|
|
origin, |
|
|
|
origin, |
|
|
|
&incoming_pdu |
|
|
|
&incoming_pdu.auth_events, |
|
|
|
.auth_events |
|
|
|
|
|
|
|
.iter() |
|
|
|
|
|
|
|
.cloned() |
|
|
|
|
|
|
|
.map(Arc::new) |
|
|
|
|
|
|
|
.collect::<Vec<_>>(), |
|
|
|
|
|
|
|
&create_event, |
|
|
|
&create_event, |
|
|
|
&room_id, |
|
|
|
&room_id, |
|
|
|
pub_key_map, |
|
|
|
pub_key_map, |
|
|
|
@ -1281,7 +1270,7 @@ fn handle_outlier_pdu<'a>( |
|
|
|
if !state_res::event_auth::auth_check( |
|
|
|
if !state_res::event_auth::auth_check( |
|
|
|
&room_version, |
|
|
|
&room_version, |
|
|
|
&incoming_pdu, |
|
|
|
&incoming_pdu, |
|
|
|
previous_create, |
|
|
|
previous_create.clone(), |
|
|
|
None, // TODO: third party invite
|
|
|
|
None, // TODO: third party invite
|
|
|
|
|k, s| auth_events.get(&(k.clone(), s.to_owned())).map(Arc::clone), |
|
|
|
|k, s| auth_events.get(&(k.clone(), s.to_owned())).map(Arc::clone), |
|
|
|
) |
|
|
|
) |
|
|
|
@ -1368,7 +1357,7 @@ async fn upgrade_outlier_to_timeline_pdu( |
|
|
|
.get_or_create_shortstatekey(&prev_pdu.kind, state_key, &db.globals) |
|
|
|
.get_or_create_shortstatekey(&prev_pdu.kind, state_key, &db.globals) |
|
|
|
.map_err(|_| "Failed to create shortstatekey.".to_owned())?; |
|
|
|
.map_err(|_| "Failed to create shortstatekey.".to_owned())?; |
|
|
|
|
|
|
|
|
|
|
|
state.insert(shortstatekey, Arc::new(prev_event.clone())); |
|
|
|
state.insert(shortstatekey, prev_event.clone()); |
|
|
|
// Now it's the state after the pdu
|
|
|
|
// Now it's the state after the pdu
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1411,7 +1400,7 @@ async fn upgrade_outlier_to_timeline_pdu( |
|
|
|
.rooms |
|
|
|
.rooms |
|
|
|
.get_or_create_shortstatekey(&prev_event.kind, state_key, &db.globals) |
|
|
|
.get_or_create_shortstatekey(&prev_event.kind, state_key, &db.globals) |
|
|
|
.map_err(|_| "Failed to create shortstatekey.".to_owned())?; |
|
|
|
.map_err(|_| "Failed to create shortstatekey.".to_owned())?; |
|
|
|
leaf_state.insert(shortstatekey, Arc::new(prev_event.event_id.clone())); |
|
|
|
leaf_state.insert(shortstatekey, prev_event.event_id.clone()); |
|
|
|
// Now it's the state after the pdu
|
|
|
|
// Now it's the state after the pdu
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1432,17 +1421,17 @@ async fn upgrade_outlier_to_timeline_pdu( |
|
|
|
db, |
|
|
|
db, |
|
|
|
) |
|
|
|
) |
|
|
|
.map_err(|_| "Failed to load auth chain.".to_owned())? |
|
|
|
.map_err(|_| "Failed to load auth chain.".to_owned())? |
|
|
|
.map(|event_id| (*event_id).clone()) |
|
|
|
.map(|event_id| event_id.clone()) |
|
|
|
.collect(), |
|
|
|
.collect(), |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let fork_states = &fork_states |
|
|
|
let fork_states = fork_states |
|
|
|
.into_iter() |
|
|
|
.into_iter() |
|
|
|
.map(|map| map.into_iter().map(|(k, id)| (k, (*id).clone())).collect()) |
|
|
|
.map(|map| map.into_iter().map(|(k, id)| (k, id.clone())).collect()) |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
.collect::<Vec<_>>(); |
|
|
|
|
|
|
|
|
|
|
|
state_at_incoming_event = match state_res::StateResolution::resolve( |
|
|
|
state_at_incoming_event = match state_res::resolve( |
|
|
|
&room_id, |
|
|
|
&room_id, |
|
|
|
room_version_id, |
|
|
|
room_version_id, |
|
|
|
&fork_states, |
|
|
|
&fork_states, |
|
|
|
@ -1463,7 +1452,7 @@ async fn upgrade_outlier_to_timeline_pdu( |
|
|
|
.rooms |
|
|
|
.rooms |
|
|
|
.get_or_create_shortstatekey(&event_type, &state_key, &db.globals) |
|
|
|
.get_or_create_shortstatekey(&event_type, &state_key, &db.globals) |
|
|
|
.map_err(|_| "Failed to get_or_create_shortstatekey".to_owned())?; |
|
|
|
.map_err(|_| "Failed to get_or_create_shortstatekey".to_owned())?; |
|
|
|
Ok((shortstatekey, Arc::new(event_id))) |
|
|
|
Ok((shortstatekey, event_id)) |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect::<StdResult<_, String>>()?, |
|
|
|
.collect::<StdResult<_, String>>()?, |
|
|
|
), |
|
|
|
), |
|
|
|
@ -1496,11 +1485,7 @@ async fn upgrade_outlier_to_timeline_pdu( |
|
|
|
let state_vec = fetch_and_handle_outliers( |
|
|
|
let state_vec = fetch_and_handle_outliers( |
|
|
|
&db, |
|
|
|
&db, |
|
|
|
origin, |
|
|
|
origin, |
|
|
|
&res.pdu_ids |
|
|
|
&res.pdu_ids, |
|
|
|
.iter() |
|
|
|
|
|
|
|
.cloned() |
|
|
|
|
|
|
|
.map(Arc::new) |
|
|
|
|
|
|
|
.collect::<Vec<_>>(), |
|
|
|
|
|
|
|
&create_event, |
|
|
|
&create_event, |
|
|
|
&room_id, |
|
|
|
&room_id, |
|
|
|
pub_key_map, |
|
|
|
pub_key_map, |
|
|
|
@ -1521,7 +1506,7 @@ async fn upgrade_outlier_to_timeline_pdu( |
|
|
|
|
|
|
|
|
|
|
|
match state.entry(shortstatekey) { |
|
|
|
match state.entry(shortstatekey) { |
|
|
|
btree_map::Entry::Vacant(v) => { |
|
|
|
btree_map::Entry::Vacant(v) => { |
|
|
|
v.insert(Arc::new(pdu.event_id.clone())); |
|
|
|
v.insert(pdu.event_id.clone()); |
|
|
|
} |
|
|
|
} |
|
|
|
btree_map::Entry::Occupied(_) => return Err( |
|
|
|
btree_map::Entry::Occupied(_) => return Err( |
|
|
|
"State event's type and state_key combination exists multiple times." |
|
|
|
"State event's type and state_key combination exists multiple times." |
|
|
|
@ -1537,9 +1522,7 @@ async fn upgrade_outlier_to_timeline_pdu( |
|
|
|
.map_err(|_| "Failed to talk to db.")? |
|
|
|
.map_err(|_| "Failed to talk to db.")? |
|
|
|
.expect("Room exists"); |
|
|
|
.expect("Room exists"); |
|
|
|
|
|
|
|
|
|
|
|
if state.get(&create_shortstatekey).map(|id| id.as_ref()) |
|
|
|
if state.get(&create_shortstatekey) != Some(&create_event.event_id) { |
|
|
|
!= Some(&create_event.event_id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return Err("Incoming event refers to wrong create event.".to_owned()); |
|
|
|
return Err("Incoming event refers to wrong create event.".to_owned()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1734,7 +1717,7 @@ async fn upgrade_outlier_to_timeline_pdu( |
|
|
|
.rooms |
|
|
|
.rooms |
|
|
|
.get_or_create_shortstatekey(&leaf_pdu.kind, state_key, &db.globals) |
|
|
|
.get_or_create_shortstatekey(&leaf_pdu.kind, state_key, &db.globals) |
|
|
|
.map_err(|_| "Failed to create shortstatekey.".to_owned())?; |
|
|
|
.map_err(|_| "Failed to create shortstatekey.".to_owned())?; |
|
|
|
leaf_state.insert(shortstatekey, Arc::new(leaf_pdu.event_id.clone())); |
|
|
|
leaf_state.insert(shortstatekey, leaf_pdu.event_id.clone()); |
|
|
|
// Now it's the state after the pdu
|
|
|
|
// Now it's the state after the pdu
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1749,9 +1732,9 @@ async fn upgrade_outlier_to_timeline_pdu( |
|
|
|
.get_or_create_shortstatekey(&incoming_pdu.kind, state_key, &db.globals) |
|
|
|
.get_or_create_shortstatekey(&incoming_pdu.kind, state_key, &db.globals) |
|
|
|
.map_err(|_| "Failed to create shortstatekey.".to_owned())?; |
|
|
|
.map_err(|_| "Failed to create shortstatekey.".to_owned())?; |
|
|
|
|
|
|
|
|
|
|
|
state_after.insert(shortstatekey, Arc::new(incoming_pdu.event_id.clone())); |
|
|
|
state_after.insert(shortstatekey, incoming_pdu.event_id.clone()); |
|
|
|
} |
|
|
|
} |
|
|
|
fork_states.push(state_after); |
|
|
|
fork_states.push(state_after.clone()); |
|
|
|
|
|
|
|
|
|
|
|
let mut update_state = false; |
|
|
|
let mut update_state = false; |
|
|
|
// 14. Use state resolution to find new room state
|
|
|
|
// 14. Use state resolution to find new room state
|
|
|
|
@ -1781,7 +1764,7 @@ async fn upgrade_outlier_to_timeline_pdu( |
|
|
|
db, |
|
|
|
db, |
|
|
|
) |
|
|
|
) |
|
|
|
.map_err(|_| "Failed to load auth chain.".to_owned())? |
|
|
|
.map_err(|_| "Failed to load auth chain.".to_owned())? |
|
|
|
.map(|event_id| (*event_id).clone()) |
|
|
|
.map(|event_id| event_id.clone()) |
|
|
|
.collect(), |
|
|
|
.collect(), |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1790,17 +1773,13 @@ async fn upgrade_outlier_to_timeline_pdu( |
|
|
|
.into_iter() |
|
|
|
.into_iter() |
|
|
|
.map(|map| { |
|
|
|
.map(|map| { |
|
|
|
map.into_iter() |
|
|
|
map.into_iter() |
|
|
|
.map(|(k, id)| { |
|
|
|
.map(|(k, id)| db.rooms.get_statekey_from_short(k).map(|k| (k, id.clone()))) |
|
|
|
db.rooms |
|
|
|
|
|
|
|
.get_statekey_from_short(k) |
|
|
|
|
|
|
|
.map(|k| (k, (*id).clone())) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.collect::<Result<StateMap<_>>>() |
|
|
|
.collect::<Result<StateMap<_>>>() |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect::<Result<Vec<_>>>() |
|
|
|
.collect::<Result<Vec<_>>>() |
|
|
|
.map_err(|_| "Failed to get_statekey_from_short.".to_owned())?; |
|
|
|
.map_err(|_| "Failed to get_statekey_from_short.".to_owned())?; |
|
|
|
|
|
|
|
|
|
|
|
let state = match state_res::StateResolution::resolve( |
|
|
|
let state = match state_res::resolve( |
|
|
|
&room_id, |
|
|
|
&room_id, |
|
|
|
room_version_id, |
|
|
|
room_version_id, |
|
|
|
fork_states, |
|
|
|
fork_states, |
|
|
|
@ -1879,7 +1858,7 @@ async fn upgrade_outlier_to_timeline_pdu( |
|
|
|
pub(crate) fn fetch_and_handle_outliers<'a>( |
|
|
|
pub(crate) fn fetch_and_handle_outliers<'a>( |
|
|
|
db: &'a Database, |
|
|
|
db: &'a Database, |
|
|
|
origin: &'a ServerName, |
|
|
|
origin: &'a ServerName, |
|
|
|
events: &'a [Arc<EventId>], |
|
|
|
events: &'a [EventId], |
|
|
|
create_event: &'a PduEvent, |
|
|
|
create_event: &'a PduEvent, |
|
|
|
room_id: &'a RoomId, |
|
|
|
room_id: &'a RoomId, |
|
|
|
pub_key_map: &'a RwLock<BTreeMap<String, BTreeMap<String, String>>>, |
|
|
|
pub_key_map: &'a RwLock<BTreeMap<String, BTreeMap<String, String>>>, |
|
|
|
@ -1934,12 +1913,12 @@ pub(crate) fn fetch_and_handle_outliers<'a>( |
|
|
|
match crate::pdu::gen_event_id_canonical_json(&res.pdu) { |
|
|
|
match crate::pdu::gen_event_id_canonical_json(&res.pdu) { |
|
|
|
Ok(t) => t, |
|
|
|
Ok(t) => t, |
|
|
|
Err(_) => { |
|
|
|
Err(_) => { |
|
|
|
back_off((**id).clone()); |
|
|
|
back_off(id.clone()); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if calculated_event_id != **id { |
|
|
|
if calculated_event_id != *id { |
|
|
|
warn!("Server didn't return event id we requested: requested: {}, we got {}. Event: {:?}", |
|
|
|
warn!("Server didn't return event id we requested: requested: {}, we got {}. Event: {:?}", |
|
|
|
id, calculated_event_id, &res.pdu); |
|
|
|
id, calculated_event_id, &res.pdu); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1959,14 +1938,14 @@ pub(crate) fn fetch_and_handle_outliers<'a>( |
|
|
|
Ok((pdu, json)) => (pdu, Some(json)), |
|
|
|
Ok((pdu, json)) => (pdu, Some(json)), |
|
|
|
Err(e) => { |
|
|
|
Err(e) => { |
|
|
|
warn!("Authentication of event {} failed: {:?}", id, e); |
|
|
|
warn!("Authentication of event {} failed: {:?}", id, e); |
|
|
|
back_off((**id).clone()); |
|
|
|
back_off(id.clone()); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Err(_) => { |
|
|
|
Err(_) => { |
|
|
|
warn!("Failed to fetch event: {}", id); |
|
|
|
warn!("Failed to fetch event: {}", id); |
|
|
|
back_off((**id).clone()); |
|
|
|
back_off(id.clone()); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -2238,9 +2217,9 @@ fn append_incoming_pdu( |
|
|
|
#[tracing::instrument(skip(starting_events, db))] |
|
|
|
#[tracing::instrument(skip(starting_events, db))] |
|
|
|
pub(crate) fn get_auth_chain<'a>( |
|
|
|
pub(crate) fn get_auth_chain<'a>( |
|
|
|
room_id: &RoomId, |
|
|
|
room_id: &RoomId, |
|
|
|
starting_events: Vec<Arc<EventId>>, |
|
|
|
starting_events: Vec<EventId>, |
|
|
|
db: &'a Database, |
|
|
|
db: &'a Database, |
|
|
|
) -> Result<impl Iterator<Item = Arc<EventId>> + 'a> { |
|
|
|
) -> Result<impl Iterator<Item = EventId> + 'a> { |
|
|
|
const NUM_BUCKETS: usize = 50; |
|
|
|
const NUM_BUCKETS: usize = 50; |
|
|
|
|
|
|
|
|
|
|
|
let mut buckets = vec![BTreeSet::new(); NUM_BUCKETS]; |
|
|
|
let mut buckets = vec![BTreeSet::new(); NUM_BUCKETS]; |
|
|
|
@ -2516,12 +2495,12 @@ pub fn get_event_authorization_route( |
|
|
|
return Err(Error::BadRequest(ErrorKind::NotFound, "Event not found.")); |
|
|
|
return Err(Error::BadRequest(ErrorKind::NotFound, "Event not found.")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let auth_chain_ids = get_auth_chain(&room_id, vec![Arc::new(body.event_id.clone())], &db)?; |
|
|
|
let auth_chain_ids = get_auth_chain(&room_id, vec![body.event_id.clone()], &db)?; |
|
|
|
|
|
|
|
|
|
|
|
Ok(get_event_authorization::v1::Response { |
|
|
|
Ok(get_event_authorization::v1::Response { |
|
|
|
auth_chain: auth_chain_ids |
|
|
|
auth_chain: auth_chain_ids |
|
|
|
.filter_map(|id| db.rooms.get_pdu_json(&id).ok()?) |
|
|
|
.filter_map(|id| Some(db.rooms.get_pdu_json(&id).ok()??)) |
|
|
|
.map(PduEvent::convert_to_outgoing_federation_event) |
|
|
|
.map(|event| PduEvent::convert_to_outgoing_federation_event(event)) |
|
|
|
.collect(), |
|
|
|
.collect(), |
|
|
|
} |
|
|
|
} |
|
|
|
.into()) |
|
|
|
.into()) |
|
|
|
@ -2574,7 +2553,7 @@ pub fn get_room_state_route( |
|
|
|
}) |
|
|
|
}) |
|
|
|
.collect(); |
|
|
|
.collect(); |
|
|
|
|
|
|
|
|
|
|
|
let auth_chain_ids = get_auth_chain(&body.room_id, vec![Arc::new(body.event_id.clone())], &db)?; |
|
|
|
let auth_chain_ids = get_auth_chain(&body.room_id, vec![body.event_id.clone()], &db)?; |
|
|
|
|
|
|
|
|
|
|
|
Ok(get_room_state::v1::Response { |
|
|
|
Ok(get_room_state::v1::Response { |
|
|
|
auth_chain: auth_chain_ids |
|
|
|
auth_chain: auth_chain_ids |
|
|
|
@ -2630,13 +2609,13 @@ pub fn get_room_state_ids_route( |
|
|
|
.rooms |
|
|
|
.rooms |
|
|
|
.state_full_ids(shortstatehash)? |
|
|
|
.state_full_ids(shortstatehash)? |
|
|
|
.into_iter() |
|
|
|
.into_iter() |
|
|
|
.map(|(_, id)| (*id).clone()) |
|
|
|
.map(|(_, id)| id) |
|
|
|
.collect(); |
|
|
|
.collect(); |
|
|
|
|
|
|
|
|
|
|
|
let auth_chain_ids = get_auth_chain(&body.room_id, vec![Arc::new(body.event_id.clone())], &db)?; |
|
|
|
let auth_chain_ids = get_auth_chain(&body.room_id, vec![body.event_id.clone()], &db)?; |
|
|
|
|
|
|
|
|
|
|
|
Ok(get_room_state_ids::v1::Response { |
|
|
|
Ok(get_room_state_ids::v1::Response { |
|
|
|
auth_chain_ids: auth_chain_ids.map(|id| (*id).clone()).collect(), |
|
|
|
auth_chain_ids: auth_chain_ids.collect(), |
|
|
|
pdu_ids, |
|
|
|
pdu_ids, |
|
|
|
} |
|
|
|
} |
|
|
|
.into()) |
|
|
|
.into()) |
|
|
|
|