StateEvent's event_id method must return owned EventId
This commit is contained in:
parent
369703a6fa
commit
ee6aa35612
15
Cargo.toml
15
Cargo.toml
@ -22,15 +22,20 @@ maplit = "1.0.2"
|
|||||||
thiserror = "1.0.20"
|
thiserror = "1.0.20"
|
||||||
tracing-subscriber = "0.2.11"
|
tracing-subscriber = "0.2.11"
|
||||||
|
|
||||||
|
[dependencies.ruma]
|
||||||
|
git = "https://github.com/ruma/ruma"
|
||||||
|
rev = "648c3f5732db7524d967e472ec587fd33fa992e9"
|
||||||
|
features = ["client-api", "federation-api", "appservice-api"]
|
||||||
|
|
||||||
#[dependencies.ruma]
|
#[dependencies.ruma]
|
||||||
#path = "../ruma/ruma"
|
#path = "../ruma/ruma"
|
||||||
#features = ["client-api", "federation-api", "appservice-api"]
|
#features = ["client-api", "federation-api", "appservice-api"]
|
||||||
|
|
||||||
[dependencies.ruma]
|
# [dependencies.ruma]
|
||||||
git = "https://github.com/timokoesters/ruma"
|
# git = "https://github.com/timokoesters/ruma"
|
||||||
branch = "timo-fed-fixes"
|
# branch = "timo-fed-fixes"
|
||||||
#rev = "aff914050eb297bd82b8aafb12158c88a9e480e1"
|
# #rev = "aff914050eb297bd82b8aafb12158c88a9e480e1"
|
||||||
features = ["client-api", "federation-api", "appservice-api"]
|
# features = ["client-api", "federation-api", "appservice-api"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
unstable-pre-spec = ["ruma/unstable-pre-spec"]
|
unstable-pre-spec = ["ruma/unstable-pre-spec"]
|
||||||
|
@ -110,7 +110,7 @@ impl StateResolution {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// update event_map to include the fetched events
|
// update event_map to include the fetched events
|
||||||
event_map.extend(events.into_iter().map(|ev| (ev.event_id().clone(), ev)));
|
event_map.extend(events.into_iter().map(|ev| (ev.event_id(), ev)));
|
||||||
// at this point our event_map == store there should be no missing events
|
// at this point our event_map == store there should be no missing events
|
||||||
|
|
||||||
tracing::debug!("event map size: {}", event_map.len());
|
tracing::debug!("event map size: {}", event_map.len());
|
||||||
@ -338,7 +338,7 @@ impl StateResolution {
|
|||||||
// This return value is the key used for sorting events,
|
// This return value is the key used for sorting events,
|
||||||
// events are then sorted by power level, time,
|
// events are then sorted by power level, time,
|
||||||
// and lexically by event_id.
|
// and lexically by event_id.
|
||||||
(-*pl, *ev.origin_server_ts(), ev.event_id().clone())
|
(-*pl, *ev.origin_server_ts(), ev.event_id())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ use ruma::{
|
|||||||
},
|
},
|
||||||
EventId, RoomId, RoomVersionId, ServerName, UserId,
|
EventId, RoomId, RoomVersionId, ServerName, UserId,
|
||||||
};
|
};
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
pub struct Requester<'a> {
|
pub struct Requester<'a> {
|
||||||
@ -118,11 +118,21 @@ impl StateEvent {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn event_id(&self) -> &EventId {
|
pub fn event_id(&self) -> EventId {
|
||||||
|
use std::convert::TryFrom;
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
Self::Full(ev) => match ev {
|
Self::Full(ev) => match ev {
|
||||||
Pdu::RoomV1Pdu(ev) => &ev.event_id,
|
Pdu::RoomV1Pdu(ev) => ev.event_id.clone(),
|
||||||
Pdu::RoomV3Pdu(ev) => ev.event_id.as_ref().expect("RoomV3Pdu did not have an event id"),
|
Pdu::RoomV3Pdu(ev) => {
|
||||||
|
let value = serde_json::to_value(ev).expect("all ruma pdus are json values");
|
||||||
|
EventId::try_from(&*format!(
|
||||||
|
"${}",
|
||||||
|
ruma::signatures::reference_hash(&value, &self.room_version())
|
||||||
|
.expect("ruma can calculate reference hashes")
|
||||||
|
))
|
||||||
|
.expect("ruma's reference hashes are valid event ids")
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Self::Sync(_ev) => panic!("Stubs don't have an event id"),
|
Self::Sync(_ev) => panic!("Stubs don't have an event id"),
|
||||||
}
|
}
|
||||||
@ -337,3 +347,23 @@ impl StateEvent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fn process_incoming_pdu(
|
||||||
|
// pdu: &ruma::Raw<ruma::events::pdu::Pdu>,
|
||||||
|
// version: &ruma::RoomVersionId,
|
||||||
|
// ) -> (EventId, serde_json::Value) {
|
||||||
|
// let mut value = serde_json::to_value(pdu.json().get()).expect("all ruma pdus are json values");
|
||||||
|
// let event_id = EventId::try_from(&*format!(
|
||||||
|
// "${}",
|
||||||
|
// ruma::signatures::reference_hash(&value, version)
|
||||||
|
// .expect("ruma can calculate reference hashes")
|
||||||
|
// ))
|
||||||
|
// .expect("ruma's reference hashes are valid event ids");
|
||||||
|
|
||||||
|
// value
|
||||||
|
// .as_object_mut()
|
||||||
|
// .expect("ruma pdus are json objects")
|
||||||
|
// .insert("event_id".to_owned(), event_id.to_string().into());
|
||||||
|
|
||||||
|
// (event_id, value)
|
||||||
|
// }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user