fix: inviting dendrite users

This commit is contained in:
Timo Kösters 2021-08-30 10:56:41 +02:00
parent d57c19802d
commit 1b25e78e3a
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
2 changed files with 15 additions and 3 deletions

View file

@ -973,6 +973,14 @@ pub async fn invite_helper<'a>(
(room_version_id, pdu_json, invite_room_state)
};
// Generate event id
let expected_event_id = EventId::try_from(&*format!(
"${}",
ruma::signatures::reference_hash(&pdu_json, &room_version_id)
.expect("ruma can calculate reference hashes")
))
.expect("ruma's reference hashes are valid event ids");
let response = db
.sending
.send_federation_request(
@ -980,9 +988,9 @@ pub async fn invite_helper<'a>(
user_id.server_name(),
create_invite::v2::Request {
room_id: room_id.clone(),
event_id: ruma::event_id!("$receivingservershouldsetthis"),
event_id: expected_event_id.clone(),
room_version: room_version_id,
event: PduEvent::convert_to_outgoing_federation_event(pdu_json),
event: PduEvent::convert_to_outgoing_federation_event(pdu_json.clone()),
invite_room_state,
},
)
@ -1002,6 +1010,10 @@ pub async fn invite_helper<'a>(
}
};
if expected_event_id != event_id {
warn!("Server {} changed invite event, that's not allowed in the spec: ours: {:?}, theirs: {:?}", user_id.server_name(), pdu_json, value);
}
let origin = serde_json::from_value::<Box<ServerName>>(
serde_json::to_value(value.get("origin").ok_or(Error::BadRequest(
ErrorKind::InvalidParam,

View file

@ -1526,7 +1526,7 @@ async fn upgrade_outlier_to_timeline_pdu(
extremities,
state_ids_compressed,
soft_fail,
&state_lock
&state_lock,
)
.map_err(|_| "Failed to add pdu to db.".to_owned())?;