fix: various improvements and fixes

This commit is contained in:
Timo Kösters 2021-03-23 12:59:27 +01:00
parent 363c629faf
commit 3ea7d162db
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
9 changed files with 67 additions and 57 deletions

18
Cargo.lock generated
View file

@ -1623,6 +1623,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma" name = "ruma"
version = "0.0.2" version = "0.0.2"
source = "git+https://github.com/ruma/ruma?rev=f196f5b6f164973d6b343af31ab4e0457f743675#f196f5b6f164973d6b343af31ab4e0457f743675"
dependencies = [ dependencies = [
"assign", "assign",
"js_int", "js_int",
@ -1642,6 +1643,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-api" name = "ruma-api"
version = "0.17.0-alpha.2" version = "0.17.0-alpha.2"
source = "git+https://github.com/ruma/ruma?rev=f196f5b6f164973d6b343af31ab4e0457f743675#f196f5b6f164973d6b343af31ab4e0457f743675"
dependencies = [ dependencies = [
"http", "http",
"percent-encoding", "percent-encoding",
@ -1656,6 +1658,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-api-macros" name = "ruma-api-macros"
version = "0.17.0-alpha.2" version = "0.17.0-alpha.2"
source = "git+https://github.com/ruma/ruma?rev=f196f5b6f164973d6b343af31ab4e0457f743675#f196f5b6f164973d6b343af31ab4e0457f743675"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
@ -1666,6 +1669,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-appservice-api" name = "ruma-appservice-api"
version = "0.2.0-alpha.2" version = "0.2.0-alpha.2"
source = "git+https://github.com/ruma/ruma?rev=f196f5b6f164973d6b343af31ab4e0457f743675#f196f5b6f164973d6b343af31ab4e0457f743675"
dependencies = [ dependencies = [
"ruma-api", "ruma-api",
"ruma-common", "ruma-common",
@ -1679,6 +1683,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-client-api" name = "ruma-client-api"
version = "0.10.0-alpha.2" version = "0.10.0-alpha.2"
source = "git+https://github.com/ruma/ruma?rev=f196f5b6f164973d6b343af31ab4e0457f743675#f196f5b6f164973d6b343af31ab4e0457f743675"
dependencies = [ dependencies = [
"assign", "assign",
"http", "http",
@ -1697,6 +1702,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-common" name = "ruma-common"
version = "0.3.0-alpha.1" version = "0.3.0-alpha.1"
source = "git+https://github.com/ruma/ruma?rev=f196f5b6f164973d6b343af31ab4e0457f743675#f196f5b6f164973d6b343af31ab4e0457f743675"
dependencies = [ dependencies = [
"js_int", "js_int",
"maplit", "maplit",
@ -1709,6 +1715,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-events" name = "ruma-events"
version = "0.22.0-alpha.2" version = "0.22.0-alpha.2"
source = "git+https://github.com/ruma/ruma?rev=f196f5b6f164973d6b343af31ab4e0457f743675#f196f5b6f164973d6b343af31ab4e0457f743675"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -1722,6 +1729,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-events-macros" name = "ruma-events-macros"
version = "0.22.0-alpha.2" version = "0.22.0-alpha.2"
source = "git+https://github.com/ruma/ruma?rev=f196f5b6f164973d6b343af31ab4e0457f743675#f196f5b6f164973d6b343af31ab4e0457f743675"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
@ -1732,6 +1740,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-federation-api" name = "ruma-federation-api"
version = "0.1.0-alpha.1" version = "0.1.0-alpha.1"
source = "git+https://github.com/ruma/ruma?rev=f196f5b6f164973d6b343af31ab4e0457f743675#f196f5b6f164973d6b343af31ab4e0457f743675"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-api", "ruma-api",
@ -1746,6 +1755,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers" name = "ruma-identifiers"
version = "0.18.0-alpha.1" version = "0.18.0-alpha.1"
source = "git+https://github.com/ruma/ruma?rev=f196f5b6f164973d6b343af31ab4e0457f743675#f196f5b6f164973d6b343af31ab4e0457f743675"
dependencies = [ dependencies = [
"paste", "paste",
"rand", "rand",
@ -1759,6 +1769,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers-macros" name = "ruma-identifiers-macros"
version = "0.18.0-alpha.1" version = "0.18.0-alpha.1"
source = "git+https://github.com/ruma/ruma?rev=f196f5b6f164973d6b343af31ab4e0457f743675#f196f5b6f164973d6b343af31ab4e0457f743675"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1769,10 +1780,12 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers-validation" name = "ruma-identifiers-validation"
version = "0.2.0" version = "0.2.0"
source = "git+https://github.com/ruma/ruma?rev=f196f5b6f164973d6b343af31ab4e0457f743675#f196f5b6f164973d6b343af31ab4e0457f743675"
[[package]] [[package]]
name = "ruma-identity-service-api" name = "ruma-identity-service-api"
version = "0.0.1" version = "0.0.1"
source = "git+https://github.com/ruma/ruma?rev=f196f5b6f164973d6b343af31ab4e0457f743675#f196f5b6f164973d6b343af31ab4e0457f743675"
dependencies = [ dependencies = [
"ruma-api", "ruma-api",
"ruma-common", "ruma-common",
@ -1785,6 +1798,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-push-gateway-api" name = "ruma-push-gateway-api"
version = "0.0.1" version = "0.0.1"
source = "git+https://github.com/ruma/ruma?rev=f196f5b6f164973d6b343af31ab4e0457f743675#f196f5b6f164973d6b343af31ab4e0457f743675"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-api", "ruma-api",
@ -1799,6 +1813,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-serde" name = "ruma-serde"
version = "0.3.0" version = "0.3.0"
source = "git+https://github.com/ruma/ruma?rev=f196f5b6f164973d6b343af31ab4e0457f743675#f196f5b6f164973d6b343af31ab4e0457f743675"
dependencies = [ dependencies = [
"form_urlencoded", "form_urlencoded",
"itoa", "itoa",
@ -1811,6 +1826,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-serde-macros" name = "ruma-serde-macros"
version = "0.3.0" version = "0.3.0"
source = "git+https://github.com/ruma/ruma?rev=f196f5b6f164973d6b343af31ab4e0457f743675#f196f5b6f164973d6b343af31ab4e0457f743675"
dependencies = [ dependencies = [
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
@ -1821,6 +1837,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-signatures" name = "ruma-signatures"
version = "0.6.0-alpha.1" version = "0.6.0-alpha.1"
source = "git+https://github.com/ruma/ruma?rev=f196f5b6f164973d6b343af31ab4e0457f743675#f196f5b6f164973d6b343af31ab4e0457f743675"
dependencies = [ dependencies = [
"base64 0.13.0", "base64 0.13.0",
"ring", "ring",
@ -2088,6 +2105,7 @@ checksum = "3015a7d0a5fd5105c91c3710d42f9ccf0abfb287d62206484dcc67f9569a6483"
[[package]] [[package]]
name = "state-res" name = "state-res"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/ruma/state-res?rev=34cd1cb4dcdd5fb84b5df9e48e63b2e4669a2488#34cd1cb4dcdd5fb84b5df9e48e63b2e4669a2488"
dependencies = [ dependencies = [
"itertools 0.10.0", "itertools 0.10.0",
"log", "log",

View file

@ -18,15 +18,16 @@ rocket = { git = "https://github.com/SergioBenitez/Rocket.git", rev = "93e62c86e
#rocket = { git = "https://github.com/timokoesters/Rocket.git", branch = "empty_parameters", default-features = false, features = ["tls"] } #rocket = { git = "https://github.com/timokoesters/Rocket.git", branch = "empty_parameters", default-features = false, features = ["tls"] }
# Used for matrix spec type definitions and helpers # Used for matrix spec type definitions and helpers
#ruma = { git = "https://github.com/ruma/ruma", features = ["rand", "appservice-api", "client-api", "federation-api", "push-gateway-api", "unstable-pre-spec", "unstable-synapse-quirks", "unstable-exhaustive-types"], rev = "f196f5b6f164973d6b343af31ab4e0457f743675" } ruma = { git = "https://github.com/ruma/ruma", features = ["rand", "appservice-api", "client-api", "federation-api", "push-gateway-api", "unstable-pre-spec", "unstable-synapse-quirks", "unstable-exhaustive-types"], rev = "f196f5b6f164973d6b343af31ab4e0457f743675" }
#ruma = { git = "https://github.com/DevinR528/ruma", features = ["rand", "client-api", "federation-api", "push-gateway-api", "unstable-exhaustive-types", "unstable-pre-spec", "unstable-synapse-quirks"], branch = "verified-export" } #ruma = { git = "https://github.com/DevinR528/ruma", features = ["rand", "client-api", "federation-api", "push-gateway-api", "unstable-exhaustive-types", "unstable-pre-spec", "unstable-synapse-quirks"], branch = "verified-export" }
ruma = { path = "../ruma/ruma", features = ["unstable-exhaustive-types", "rand", "client-api", "federation-api", "push-gateway-api", "unstable-pre-spec", "unstable-synapse-quirks"] } #ruma = { path = "../ruma/ruma", features = ["unstable-exhaustive-types", "rand", "client-api", "federation-api", "push-gateway-api", "unstable-pre-spec", "unstable-synapse-quirks"] }
# Used when doing state resolution # Used when doing state resolution
# state-res = { git = "https://github.com/timokoesters/state-res", branch = "timo-spec-comp", features = ["unstable-pre-spec"] } # state-res = { git = "https://github.com/timokoesters/state-res", branch = "timo-spec-comp", features = ["unstable-pre-spec"] }
# TODO: remove the gen-eventid feature # TODO: remove the gen-eventid feature
#state-res = { git = "https://github.com/ruma/state-res", rev = "34cd1cb4dcdd5fb84b5df9e48e63b2e4669a2488", features = ["unstable-pre-spec", "gen-eventid"] } #state-res = { git = "https://github.com/ruma/state-res", branch = "main", features = ["unstable-pre-spec", "gen-eventid"] }
state-res = { path = "../state-res", features = ["unstable-pre-spec", "gen-eventid"] } state-res = { git = "https://github.com/ruma/state-res", rev = "34cd1cb4dcdd5fb84b5df9e48e63b2e4669a2488", features = ["unstable-pre-spec", "gen-eventid"] }
#state-res = { path = "../state-res", features = ["unstable-pre-spec", "gen-eventid"] }
# Used for long polling and federation sender, should be the same as rocket::tokio # Used for long polling and federation sender, should be the same as rocket::tokio
tokio = "1.2.0" tokio = "1.2.0"

View file

@ -24,20 +24,25 @@ pub async fn get_context_route(
)); ));
} }
let base_pdu_id = db
.rooms
.get_pdu_id(&body.event_id)?
.ok_or(Error::BadRequest(
ErrorKind::NotFound,
"Base event id not found.",
))?;
let base_token = db.rooms.pdu_count(&base_pdu_id)?;
let base_event = db let base_event = db
.rooms .rooms
.get_pdu(&body.event_id)? .get_pdu_from_id(&base_pdu_id)?
.ok_or(Error::BadRequest( .ok_or(Error::BadRequest(
ErrorKind::NotFound, ErrorKind::NotFound,
"Base event not found.", "Base event not found.",
))? ))?
.to_room_event(); .to_room_event();
let base_token = db
.rooms
.get_pdu_count(&body.event_id)?
.expect("event still exists");
let events_before = db let events_before = db
.rooms .rooms
.pdus_until(&sender_user, &body.room_id, base_token) .pdus_until(&sender_user, &body.room_id, base_token)

View file

@ -120,7 +120,7 @@ impl Database {
token_userdeviceid: db.open_tree("token_userdeviceid")?, token_userdeviceid: db.open_tree("token_userdeviceid")?,
onetimekeyid_onetimekeys: db.open_tree("onetimekeyid_onetimekeys")?, onetimekeyid_onetimekeys: db.open_tree("onetimekeyid_onetimekeys")?,
userid_lastonetimekeyupdate: db.open_tree("userid_lastonetimekeyupdate")?, userid_lastonetimekeyupdate: db.open_tree("userid_lastonetimekeyupdate")?,
keychangeid_userid: db.open_tree("devicekeychangeid_userid")?, keychangeid_userid: db.open_tree("keychangeid_userid")?,
keyid_key: db.open_tree("keyid_key")?, keyid_key: db.open_tree("keyid_key")?,
userid_masterkeyid: db.open_tree("userid_masterkeyid")?, userid_masterkeyid: db.open_tree("userid_masterkeyid")?,
userid_selfsigningkeyid: db.open_tree("userid_selfsigningkeyid")?, userid_selfsigningkeyid: db.open_tree("userid_selfsigningkeyid")?,
@ -135,7 +135,7 @@ impl Database {
readreceiptid_readreceipt: db.open_tree("readreceiptid_readreceipt")?, readreceiptid_readreceipt: db.open_tree("readreceiptid_readreceipt")?,
roomuserid_privateread: db.open_tree("roomuserid_privateread")?, // "Private" read receipt roomuserid_privateread: db.open_tree("roomuserid_privateread")?, // "Private" read receipt
roomuserid_lastprivatereadupdate: db roomuserid_lastprivatereadupdate: db
.open_tree("roomid_lastprivatereadupdate")?, .open_tree("roomuserid_lastprivatereadupdate")?,
typingid_userid: db.open_tree("typingid_userid")?, typingid_userid: db.open_tree("typingid_userid")?,
roomid_lasttypingupdate: db.open_tree("roomid_lasttypingupdate")?, roomid_lasttypingupdate: db.open_tree("roomid_lasttypingupdate")?,
presenceid_presence: db.open_tree("presenceid_presence")?, presenceid_presence: db.open_tree("presenceid_presence")?,
@ -146,7 +146,7 @@ impl Database {
roomid_pduleaves: db.open_tree("roomid_pduleaves")?, roomid_pduleaves: db.open_tree("roomid_pduleaves")?,
alias_roomid: db.open_tree("alias_roomid")?, alias_roomid: db.open_tree("alias_roomid")?,
aliasid_alias: db.open_tree("alias_roomid")?, aliasid_alias: db.open_tree("aliasid_alias")?,
publicroomids: db.open_tree("publicroomids")?, publicroomids: db.open_tree("publicroomids")?,
tokenids: db.open_tree("tokenids")?, tokenids: db.open_tree("tokenids")?,
@ -163,11 +163,11 @@ impl Database {
stateid_shorteventid: db.open_tree("stateid_shorteventid")?, stateid_shorteventid: db.open_tree("stateid_shorteventid")?,
eventid_shorteventid: db.open_tree("eventid_shorteventid")?, eventid_shorteventid: db.open_tree("eventid_shorteventid")?,
shorteventid_eventid: db.open_tree("shorteventid_eventid")?, shorteventid_eventid: db.open_tree("shorteventid_eventid")?,
shorteventid_shortstatehash: db.open_tree("eventid_shortstatehash")?, shorteventid_shortstatehash: db.open_tree("shorteventid_shortstatehash")?,
roomid_shortstatehash: db.open_tree("roomid_shortstatehash")?, roomid_shortstatehash: db.open_tree("roomid_shortstatehash")?,
statehash_shortstatehash: db.open_tree("statehash_shortstatehash")?, statehash_shortstatehash: db.open_tree("statehash_shortstatehash")?,
eventid_outlierpdu: db.open_tree("roomeventid_outlierpdu")?, eventid_outlierpdu: db.open_tree("eventid_outlierpdu")?,
prevevent_parent: db.open_tree("prevevent_parent")?, prevevent_parent: db.open_tree("prevevent_parent")?,
}, },
account_data: account_data::AccountData { account_data: account_data::AccountData {
@ -179,7 +179,7 @@ impl Database {
key_backups: key_backups::KeyBackups { key_backups: key_backups::KeyBackups {
backupid_algorithm: db.open_tree("backupid_algorithm")?, backupid_algorithm: db.open_tree("backupid_algorithm")?,
backupid_etag: db.open_tree("backupid_etag")?, backupid_etag: db.open_tree("backupid_etag")?,
backupkeyid_backup: db.open_tree("backupkeyid_backupmetadata")?, backupkeyid_backup: db.open_tree("backupkeyid_backup")?,
}, },
transaction_ids: transaction_ids::TransactionIds { transaction_ids: transaction_ids::TransactionIds {
userdevicetxnid_response: db.open_tree("userdevicetxnid_response")?, userdevicetxnid_response: db.open_tree("userdevicetxnid_response")?,

View file

@ -469,7 +469,7 @@ async fn send_notice(
name: &str, name: &str,
) -> Result<()> { ) -> Result<()> {
// TODO: email // TODO: email
if pusher.kind == Some(PusherKind::Http) { if pusher.kind == Some(PusherKind::Email) {
return Ok(()); return Ok(());
} }

View file

@ -1524,7 +1524,7 @@ impl Rooms {
let mut aliasid = room_id.as_bytes().to_vec(); let mut aliasid = room_id.as_bytes().to_vec();
aliasid.push(0xff); aliasid.push(0xff);
aliasid.extend_from_slice(&globals.next_count()?.to_be_bytes()); aliasid.extend_from_slice(&globals.next_count()?.to_be_bytes());
self.aliasid_alias.insert(aliasid, &*alias.alias())?; self.aliasid_alias.insert(aliasid, &*alias.as_bytes())?;
} else { } else {
// room_id=None means remove alias // room_id=None means remove alias
let room_id = self let room_id = self

View file

@ -108,7 +108,6 @@ impl Sending {
let mut subscriber = servernamepduids.watch_prefix(b""); let mut subscriber = servernamepduids.watch_prefix(b"");
loop { loop {
println!(".");
select! { select! {
Some(response) = futures.next() => { Some(response) = futures.next() => {
match response { match response {
@ -262,8 +261,6 @@ impl Sending {
servercurrentpdus.insert(&key, &[]).unwrap(); servercurrentpdus.insert(&key, &[]).unwrap();
servernamepduids.remove(&key).unwrap(); servernamepduids.remove(&key).unwrap();
dbg!("there is a future");
futures.push( futures.push(
Self::handle_event( Self::handle_event(
outgoing_kind, outgoing_kind,
@ -292,7 +289,6 @@ impl Sending {
#[tracing::instrument(skip(self))] #[tracing::instrument(skip(self))]
pub fn send_pdu(&self, server: &ServerName, pdu_id: &[u8]) -> Result<()> { pub fn send_pdu(&self, server: &ServerName, pdu_id: &[u8]) -> Result<()> {
dbg!(&server);
let mut key = server.as_bytes().to_vec(); let mut key = server.as_bytes().to_vec();
key.push(0xff); key.push(0xff);
key.extend_from_slice(pdu_id); key.extend_from_slice(pdu_id);
@ -350,7 +346,6 @@ impl Sending {
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let permit = db.sending.maximum_requests.acquire().await; let permit = db.sending.maximum_requests.acquire().await;
error!("sending pdus to {}: {:#?}", server, pdu_jsons);
let response = appservice_server::send_request( let response = appservice_server::send_request(
&db.globals, &db.globals,
db.appservice db.appservice
@ -458,7 +453,6 @@ impl Sending {
let permit = db.sending.maximum_requests.acquire().await; let permit = db.sending.maximum_requests.acquire().await;
error!("sending pdu to {}: {:#?}", userid, pdu);
let _response = pusher::send_push_notice( let _response = pusher::send_push_notice(
&userid, &userid,
unread, unread,
@ -506,7 +500,6 @@ impl Sending {
let permit = db.sending.maximum_requests.acquire().await; let permit = db.sending.maximum_requests.acquire().await;
error!("sending pdus to {}: {:#?}", server, pdu_jsons);
let response = server_server::send_request( let response = server_server::send_request(
&db.globals, &db.globals,
&*server, &*server,
@ -523,7 +516,7 @@ impl Sending {
) )
.await .await
.map(|response| { .map(|response| {
error!("server response: {:?}", response); info!("server response: {:?}", response);
kind.clone() kind.clone()
}) })
.map_err(|e| (kind, e)); .map_err(|e| (kind, e));

View file

@ -219,6 +219,7 @@ where
"Access-Control-Allow-Headers", "Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept, Authorization", "Origin, X-Requested-With, Content-Type, Accept, Authorization",
); );
response.raw_header("Access-Control-Max-Age", "86400");
response.ok() response.ok()
} }
Err(_) => Err(Status::InternalServerError), Err(_) => Err(Status::InternalServerError),

View file

@ -863,8 +863,6 @@ pub async fn send_transaction_message_route<'a>(
.map(|(_, pdu)| (pdu.event_id().clone(), pdu)), .map(|(_, pdu)| (pdu.event_id().clone(), pdu)),
); );
debug!("auth events: {:?}", auth_cache);
let res = match state_res::StateResolution::resolve( let res = match state_res::StateResolution::resolve(
pdu.room_id(), pdu.room_id(),
&RoomVersionId::Version6, &RoomVersionId::Version6,
@ -952,7 +950,7 @@ type AsyncRecursiveResult<'a, T> = Pin<Box<dyn Future<Output = StdResult<T, Stri
/// 5. reject "due to auth events" if the event doesn't pass auth based on the auth events /// 5. reject "due to auth events" if the event doesn't pass auth based on the auth events
/// 7. if not timeline event: stop /// 7. if not timeline event: stop
/// 8. fetch any missing prev events doing all checks listed here starting at 1. These are timeline events /// 8. fetch any missing prev events doing all checks listed here starting at 1. These are timeline events
#[tracing::instrument(skip(db))] #[tracing::instrument(skip(db, pub_key_map, auth_cache))]
fn validate_event<'a>( fn validate_event<'a>(
db: &'a Database, db: &'a Database,
value: CanonicalJsonObject, value: CanonicalJsonObject,
@ -998,29 +996,26 @@ fn validate_event<'a>(
} }
}; };
pub_key_map.insert(dbg!(signature_server.clone()), dbg!(keys)); pub_key_map.insert(signature_server.clone(), keys);
} }
let mut val = match ruma::signatures::verify_event( let mut val =
dbg!(&pub_key_map), match ruma::signatures::verify_event(&pub_key_map, &value, &RoomVersionId::Version5) {
&value, Ok(ver) => {
&RoomVersionId::Version5, if let ruma::signatures::Verified::Signatures = ver {
) { match ruma::signatures::redact(&value, &RoomVersionId::Version6) {
Ok(ver) => { Ok(obj) => obj,
if let ruma::signatures::Verified::Signatures = ver { Err(_) => return Err("Redaction failed".to_string()),
match ruma::signatures::redact(&value, &RoomVersionId::Version6) { }
Ok(obj) => obj, } else {
Err(_) => return Err("Redaction failed".to_string()), value
} }
} else {
value
} }
} Err(e) => {
Err(_e) => { error!("{:?}: {}", value, e);
error!("{}", _e); return Err("Signature verification failed".to_string());
return Err("Signature verification failed".to_string()); }
} };
};
// Now that we have checked the signature and hashes we can add the eventID and convert // Now that we have checked the signature and hashes we can add the eventID and convert
// to our PduEvent type also finally verifying the first step listed above // to our PduEvent type also finally verifying the first step listed above
@ -1085,7 +1080,7 @@ fn validate_event<'a>(
}) })
} }
#[tracing::instrument(skip(db))] #[tracing::instrument(skip(db, key_map, auth_cache))]
async fn fetch_check_auth_events( async fn fetch_check_auth_events(
db: &Database, db: &Database,
origin: &ServerName, origin: &ServerName,
@ -1108,7 +1103,7 @@ async fn fetch_check_auth_events(
/// ///
/// If the event is unknown to the `auth_cache` it is added. This guarantees that any /// If the event is unknown to the `auth_cache` it is added. This guarantees that any
/// event we need to know of will be present. /// event we need to know of will be present.
#[tracing::instrument(skip(db))] //#[tracing::instrument(skip(db, key_map, auth_cache))]
pub(crate) async fn fetch_events( pub(crate) async fn fetch_events(
db: &Database, db: &Database,
origin: &ServerName, origin: &ServerName,
@ -1175,11 +1170,8 @@ pub(crate) async fn fetch_signing_keys(
origin: &ServerName, origin: &ServerName,
signature_ids: Vec<&String>, signature_ids: Vec<&String>,
) -> Result<BTreeMap<String, String>> { ) -> Result<BTreeMap<String, String>> {
let contains_all_ids = |keys: &BTreeMap<String, String>| { let contains_all_ids =
signature_ids |keys: &BTreeMap<String, String>| signature_ids.iter().all(|&id| keys.contains_key(id));
.iter()
.all(|&id| dbg!(dbg!(&keys).contains_key(dbg!(id))))
};
let mut result = db let mut result = db
.globals .globals
@ -1273,7 +1265,7 @@ pub(crate) async fn calculate_forward_extremities(
db: &Database, db: &Database,
pdu: &PduEvent, pdu: &PduEvent,
) -> Result<Vec<EventId>> { ) -> Result<Vec<EventId>> {
let mut current_leaves = dbg!(db.rooms.get_pdu_leaves(pdu.room_id())?); let mut current_leaves = db.rooms.get_pdu_leaves(pdu.room_id())?;
let mut is_incoming_leaf = true; let mut is_incoming_leaf = true;
// Make sure the incoming event is not already a forward extremity // Make sure the incoming event is not already a forward extremity
@ -1344,7 +1336,7 @@ pub(crate) async fn build_forward_extremity_snapshots(
Some(leave_pdu) => { Some(leave_pdu) => {
let pdu_shortstatehash = db let pdu_shortstatehash = db
.rooms .rooms
.pdu_shortstatehash(dbg!(&leave_pdu.event_id))? .pdu_shortstatehash(&leave_pdu.event_id)?
.ok_or_else(|| Error::bad_database("Found pdu with no statehash in db."))?; .ok_or_else(|| Error::bad_database("Found pdu with no statehash in db."))?;
if current_shortstatehash.as_ref() == Some(&pdu_shortstatehash) { if current_shortstatehash.as_ref() == Some(&pdu_shortstatehash) {