mirror of
https://forgejo.ellis.link/continuwuation/continuwuity/
synced 2026-10-23 09:02:24 +00:00
fix: Ensure events received from federated invites have event IDs
This commit is contained in:
1 parent
b0aa49901e
commit
d7d0a9bb3d
5 files changed
+18
-42
No files matched your search
@@ -305,7 +305,7 @@ async fn validate_invite_state(
|
||||
"PDU in invite state (index {idx}) violates the room event format"
|
||||
)));
|
||||
};
|
||||
let (state_event_room_id, state_event_id, state_event_json) = services
|
||||
let (state_event_room_id, state_event_id, mut state_event_json) = services
|
||||
.rooms
|
||||
.event_handler
|
||||
.parse_incoming_pdu(&raw_pdu, Some(room_version_rules))
|
||||
@@ -349,6 +349,7 @@ async fn validate_invite_state(
|
||||
entry.key(),
|
||||
))),
|
||||
| Entry::Vacant(entry) => {
|
||||
state_event_json.insert("event_id".to_owned(), state_event_id.to_string().into());
|
||||
if entry.key().0 == StateEventType::RoomCreate {
|
||||
// Ensure this is a legal create event.
|
||||
let pdu_event =
|
||||
|
||||
@@ -195,5 +195,6 @@ pub(crate) async fn validate_any_membership_event(
|
||||
err!(Request(InvalidParam("Membership event violates the room event format: {e}")))
|
||||
})?;
|
||||
|
||||
// pdu.insert("event_id".to_owned(), template_event_id.to_string().into());
|
||||
Ok((pdu, membership.into(), sender_user, recipient_user))
|
||||
}
|
||||
@@ -120,6 +120,12 @@ pub async fn signature_hash_check_2_3(
|
||||
pdu_json: CanonicalJsonObject,
|
||||
room_version_rules: &RoomVersionRules,
|
||||
) -> Result<CanonicalJsonObject> {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
if pdu_json.contains_key("event_id") {
|
||||
conduwuit::warn!("Checking signature of a PDU that has an `event_id` present");
|
||||
}
|
||||
}
|
||||
match self
|
||||
.services
|
||||
.server_keys
|
||||
|
||||
@@ -395,7 +395,7 @@ async fn build_state_map(
|
||||
.iter()
|
||||
.stream()
|
||||
.wide_filter_map(async |pdu| {
|
||||
let (event_room_id, event_id, value) = self
|
||||
let (event_room_id, event_id, mut value) = self
|
||||
.services
|
||||
.event_handler
|
||||
.parse_incoming_pdu(pdu, Some(room_version_rules))
|
||||
@@ -406,6 +406,7 @@ async fn build_state_map(
|
||||
warn!(%event_id, expected=%room_id, actual=%event_room_id, "PDU in room state belongs to a different room (dropping)");
|
||||
return None;
|
||||
}
|
||||
// value.insert("event_id".to_owned(), event_id.to_string().into());
|
||||
if self.services.pdu_metadata.is_event_rejected(&event_id).await {
|
||||
// Rejection will be re-evaluated later
|
||||
trace!(%event_id, "Un-rejecting event");
|
||||
@@ -478,16 +479,8 @@ async fn process_send_join_auth_chain(
|
||||
})
|
||||
.collect::<HashMap<_, _>>()
|
||||
.await;
|
||||
let events_per_second = response.room_state.auth_chain.len().saturating_div(
|
||||
auth_chain_timing_start
|
||||
.elapsed()
|
||||
.as_secs()
|
||||
.try_into()
|
||||
.expect("u64 must fit into usize"),
|
||||
);
|
||||
debug!(
|
||||
elapsed=?auth_chain_timing_start.elapsed(),
|
||||
%events_per_second,
|
||||
"Finished validating auth chain ({}/{} events passed validation)",
|
||||
unauthed_auth_chain.len(),
|
||||
response.room_state.auth_chain.len()
|
||||
@@ -547,16 +540,8 @@ async fn process_send_join_auth_chain(
|
||||
})
|
||||
.collect::<BTreeMap<_, _>>()
|
||||
.await;
|
||||
let events_per_second = unauthed_auth_chain.len().saturating_div(
|
||||
auth_chain_timing_start
|
||||
.elapsed()
|
||||
.as_secs()
|
||||
.try_into()
|
||||
.expect("u64 must fit into usize"),
|
||||
);
|
||||
debug!(
|
||||
elapsed=?auth_chain_timing_start.elapsed(),
|
||||
%events_per_second,
|
||||
"Finished authentication auth chain ({}/{} events passed authentication)",
|
||||
auth_chain.len(),
|
||||
unauthed_auth_chain.len()
|
||||
@@ -577,14 +562,7 @@ async fn process_send_join_auth_chain(
|
||||
}
|
||||
})
|
||||
.await;
|
||||
let events_per_second = auth_chain.len().saturating_div(
|
||||
auth_chain_timing_start
|
||||
.elapsed()
|
||||
.as_secs()
|
||||
.try_into()
|
||||
.expect("u64 must fit into usize"),
|
||||
);
|
||||
info!(elapsed=?auth_chain_timing_start.elapsed(), %events_per_second, "Finished processing authentication events");
|
||||
info!(elapsed=?auth_chain_timing_start.elapsed(), "Finished processing authentication events");
|
||||
|
||||
Ok(auth_chain)
|
||||
}
|
||||
@@ -661,16 +639,8 @@ async fn process_send_join_state(
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.await;
|
||||
let events_per_second = state_size.saturating_div(
|
||||
state_timing_start
|
||||
.elapsed()
|
||||
.as_secs()
|
||||
.try_into()
|
||||
.expect("u64 must fit into usize"),
|
||||
);
|
||||
debug!(
|
||||
elapsed=?state_timing_start.elapsed(),
|
||||
%events_per_second,
|
||||
"Finished validation and authentication of room state ({}/{} events retained)",
|
||||
state_before.len(),
|
||||
state_size,
|
||||
@@ -695,16 +665,8 @@ async fn process_send_join_state(
|
||||
})
|
||||
.await;
|
||||
|
||||
let events_per_second = state_before.len().saturating_div(
|
||||
state_timing_start
|
||||
.elapsed()
|
||||
.as_secs()
|
||||
.try_into()
|
||||
.expect("u64 must fit into usize"),
|
||||
);
|
||||
info!(
|
||||
elapsed=?state_timing_start.elapsed(),
|
||||
%events_per_second,
|
||||
"Finished processing send join state ({}/{} events)",
|
||||
state_before.len(),
|
||||
state_size,
|
||||
|
||||
@@ -18,6 +18,12 @@ pub fn hash_and_sign_event(
|
||||
object: &mut CanonicalJsonObject,
|
||||
room_version_rules: &RoomVersionRules,
|
||||
) -> Result {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
if object.contains_key("event_id") {
|
||||
conduwuit::warn!("Signing a PDU that has an `event_id` present");
|
||||
}
|
||||
}
|
||||
hash_and_sign_event(
|
||||
self.services.globals.server_name().as_str(),
|
||||
self.keypair(),
|
||||
|
||||
Reference in new issue
Block a user