1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-09-15 18:57:03 +00:00

fix: don't lookup create event when converting stripped state

by making the caller pass the room version rules, fixing stripped state conversion for invites over federation

(cherry picked from commit 03dfa72b8f)
This commit is contained in:
Matthias Ahouansou 2025-08-15 23:57:11 +02:00
parent 9bba85c7e5
commit 7a45c25d7a
No known key found for this signature in database
3 changed files with 5 additions and 11 deletions

View file

@ -231,7 +231,7 @@ pub async fn knock_room_route(
.to_stripped_state_event()
.into(),
);
let stripped_state = utils::convert_stripped_state(stripped_state, &room_id)?;
let stripped_state = utils::convert_stripped_state(stripped_state, &rules)?;
services().rooms.state_cache.update_membership(
&room_id,

View file

@ -2169,7 +2169,7 @@ pub async fn create_invite_route(
})?;
invite_state.push(pdu.to_stripped_state_event().into());
let invite_state = utils::convert_stripped_state(invite_state, &room_id)?;
let invite_state = utils::convert_stripped_state(invite_state, &rules)?;
// If we are active in the room, the remote server will notify us about the join via /send
if !services()

View file

@ -22,7 +22,7 @@ use std::{
time::{SystemTime, UNIX_EPOCH},
};
use crate::{service::pdu::gen_event_id_canonical_json, services, Result};
use crate::{service::pdu::gen_event_id_canonical_json, Result};
pub fn millis_since_unix_epoch() -> u64 {
SystemTime::now()
@ -202,20 +202,14 @@ impl fmt::Display for HtmlEscape<'_> {
/// Converts `RawStrippedState` (federation format) into `Raw<StrippedState>` (client format)
pub fn convert_stripped_state(
stripped_state: Vec<RawStrippedState>,
room_id: &RoomId,
rules: &RoomVersionRules,
) -> Result<Vec<Raw<StrippedState>>> {
stripped_state
.into_iter()
.map(|stripped_state| match stripped_state {
RawStrippedState::Stripped(state) => Ok(state.cast()),
RawStrippedState::Pdu(state) => {
let rules = services()
.rooms
.state
.get_room_version(room_id)?
.rules()
.expect("Supported room version must have rules.");
let (event_id, mut event) = gen_event_id_canonical_json(&state, &rules)?;
let (event_id, mut event) = gen_event_id_canonical_json(&state, rules)?;
event.retain(|k, _| {
matches!(