diff --git a/src/client_server/membership.rs b/src/client_server/membership.rs
index 29926e3bb68a368593ee3015eca56cc5717096b4..0a7ca812689edb4f969f4b6ad77424b844531d42 100644
--- a/src/client_server/membership.rs
+++ b/src/client_server/membership.rs
@@ -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,
diff --git a/src/server_server.rs b/src/server_server.rs
index 42d8185c5aa7d2ba8a64b93484a24de4489c1480..3682a49328eb38d995d5de22124096e43d18b173 100644
--- a/src/server_server.rs
+++ b/src/server_server.rs
@@ -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())?;