mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-08-16 18:01:35 +00:00
fix: stripped state conversion on invite
by making the caller pass the room version rules, instead of trying to lookup the create event
This commit is contained in:
parent
92ce47aa71
commit
44051ff631
3 changed files with 5 additions and 11 deletions
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue