Fix get_closest_parent and cleanup federation/send/:txn

next
Devin Ragotzy 2020-11-08 13:54:59 -05:00 committed by Timo Kösters
parent b13049a6fa
commit acd144e934
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4
6 changed files with 69 additions and 334 deletions

286
Cargo.lock generated
View File

@ -221,7 +221,7 @@ dependencies = [
"reqwest", "reqwest",
"ring", "ring",
"rocket", "rocket",
"ruma 0.0.1 (git+https://github.com/DevinR528/ruma?branch=unstable-join)", "ruma",
"rust-argon2", "rust-argon2",
"serde", "serde",
"serde_json", "serde_json",
@ -1611,33 +1611,15 @@ source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a
dependencies = [ dependencies = [
"assign", "assign",
"js_int", "js_int",
"ruma-api 0.17.0-alpha.1 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-api",
"ruma-appservice-api 0.2.0-alpha.1 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-appservice-api",
"ruma-client-api 0.10.0-alpha.1 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-client-api",
"ruma-common 0.2.0 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-common",
"ruma-events 0.22.0-alpha.1 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-events",
"ruma-federation-api 0.0.3 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-federation-api",
"ruma-identifiers 0.17.4 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-identifiers",
"ruma-serde 0.2.3 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-serde",
"ruma-signatures 0.6.0-dev.1 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-signatures",
]
[[package]]
name = "ruma"
version = "0.0.1"
source = "git+https://github.com/DevinR528/ruma?branch=unstable-join#424b138d84ccc47c0b212708a54f66bf88f7d57a"
dependencies = [
"assign",
"js_int",
"ruma-api 0.17.0-alpha.1 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-appservice-api 0.2.0-alpha.1 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-client-api 0.10.0-alpha.1 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-common 0.2.0 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-events 0.22.0-alpha.1 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-federation-api 0.0.3 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-identifiers 0.17.4 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-serde 0.2.3 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-signatures 0.6.0-dev.1 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
] ]
[[package]] [[package]]
@ -1647,27 +1629,10 @@ source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a
dependencies = [ dependencies = [
"http", "http",
"percent-encoding", "percent-encoding",
"ruma-api-macros 0.17.0-alpha.1 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-api-macros",
"ruma-common 0.2.0 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-common",
"ruma-identifiers 0.17.4 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-identifiers",
"ruma-serde 0.2.3 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-serde",
"serde",
"serde_json",
"strum",
"thiserror",
]
[[package]]
name = "ruma-api"
version = "0.17.0-alpha.1"
source = "git+https://github.com/DevinR528/ruma?branch=unstable-join#424b138d84ccc47c0b212708a54f66bf88f7d57a"
dependencies = [
"http",
"percent-encoding",
"ruma-api-macros 0.17.0-alpha.1 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-common 0.2.0 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-identifiers 0.17.4 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-serde 0.2.3 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"serde", "serde",
"serde_json", "serde_json",
"strum", "strum",
@ -1685,39 +1650,15 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "ruma-api-macros"
version = "0.17.0-alpha.1"
source = "git+https://github.com/DevinR528/ruma?branch=unstable-join#424b138d84ccc47c0b212708a54f66bf88f7d57a"
dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "ruma-appservice-api" name = "ruma-appservice-api"
version = "0.2.0-alpha.1" version = "0.2.0-alpha.1"
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889" source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
dependencies = [ dependencies = [
"ruma-api 0.17.0-alpha.1 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-api",
"ruma-common 0.2.0 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-common",
"ruma-events 0.22.0-alpha.1 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-events",
"ruma-identifiers 0.17.4 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-identifiers",
"serde",
"serde_json",
]
[[package]]
name = "ruma-appservice-api"
version = "0.2.0-alpha.1"
source = "git+https://github.com/DevinR528/ruma?branch=unstable-join#424b138d84ccc47c0b212708a54f66bf88f7d57a"
dependencies = [
"ruma-api 0.17.0-alpha.1 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-common 0.2.0 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-events 0.22.0-alpha.1 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-identifiers 0.17.4 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"serde", "serde",
"serde_json", "serde_json",
] ]
@ -1732,31 +1673,11 @@ dependencies = [
"js_int", "js_int",
"maplit", "maplit",
"percent-encoding", "percent-encoding",
"ruma-api 0.17.0-alpha.1 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-api",
"ruma-common 0.2.0 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-common",
"ruma-events 0.22.0-alpha.1 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-events",
"ruma-identifiers 0.17.4 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-identifiers",
"ruma-serde 0.2.3 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-serde",
"serde",
"serde_json",
"strum",
]
[[package]]
name = "ruma-client-api"
version = "0.10.0-alpha.1"
source = "git+https://github.com/DevinR528/ruma?branch=unstable-join#424b138d84ccc47c0b212708a54f66bf88f7d57a"
dependencies = [
"assign",
"http",
"js_int",
"maplit",
"percent-encoding",
"ruma-api 0.17.0-alpha.1 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-common 0.2.0 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-events 0.22.0-alpha.1 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-identifiers 0.17.4 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-serde 0.2.3 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"serde", "serde",
"serde_json", "serde_json",
"strum", "strum",
@ -1768,23 +1689,9 @@ version = "0.2.0"
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889" source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common-macros 0.2.0 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-common-macros",
"ruma-identifiers 0.17.4 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-identifiers",
"ruma-serde 0.2.3 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-serde",
"serde",
"serde_json",
"strum",
]
[[package]]
name = "ruma-common"
version = "0.2.0"
source = "git+https://github.com/DevinR528/ruma?branch=unstable-join#424b138d84ccc47c0b212708a54f66bf88f7d57a"
dependencies = [
"js_int",
"ruma-common-macros 0.2.0 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-identifiers 0.17.4 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-serde 0.2.3 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"serde", "serde",
"serde_json", "serde_json",
"strum", "strum",
@ -1801,42 +1708,16 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "ruma-common-macros"
version = "0.2.0"
source = "git+https://github.com/DevinR528/ruma?branch=unstable-join#424b138d84ccc47c0b212708a54f66bf88f7d57a"
dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "ruma-events" name = "ruma-events"
version = "0.22.0-alpha.1" version = "0.22.0-alpha.1"
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889" source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common 0.2.0 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-common",
"ruma-events-macros 0.22.0-alpha.1 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-events-macros",
"ruma-identifiers 0.17.4 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-identifiers",
"ruma-serde 0.2.3 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-serde",
"serde",
"serde_json",
"strum",
]
[[package]]
name = "ruma-events"
version = "0.22.0-alpha.1"
source = "git+https://github.com/DevinR528/ruma?branch=unstable-join#424b138d84ccc47c0b212708a54f66bf88f7d57a"
dependencies = [
"js_int",
"ruma-common 0.2.0 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-events-macros 0.22.0-alpha.1 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-identifiers 0.17.4 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-serde 0.2.3 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"serde", "serde",
"serde_json", "serde_json",
"strum", "strum",
@ -1853,43 +1734,17 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "ruma-events-macros"
version = "0.22.0-alpha.1"
source = "git+https://github.com/DevinR528/ruma?branch=unstable-join#424b138d84ccc47c0b212708a54f66bf88f7d57a"
dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "ruma-federation-api" name = "ruma-federation-api"
version = "0.0.3" version = "0.0.3"
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889" source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-api 0.17.0-alpha.1 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-api",
"ruma-common 0.2.0 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-common",
"ruma-events 0.22.0-alpha.1 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-events",
"ruma-identifiers 0.17.4 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-identifiers",
"ruma-serde 0.2.3 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-serde",
"serde",
"serde_json",
]
[[package]]
name = "ruma-federation-api"
version = "0.0.3"
source = "git+https://github.com/DevinR528/ruma?branch=unstable-join#424b138d84ccc47c0b212708a54f66bf88f7d57a"
dependencies = [
"js_int",
"ruma-api 0.17.0-alpha.1 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-common 0.2.0 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-events 0.22.0-alpha.1 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-identifiers 0.17.4 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-serde 0.2.3 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"serde", "serde",
"serde_json", "serde_json",
] ]
@ -1898,23 +1753,11 @@ dependencies = [
name = "ruma-identifiers" name = "ruma-identifiers"
version = "0.17.4" version = "0.17.4"
source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889" source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889#c15382ca41262058302959eac4029ab4a1ea5889"
dependencies = [
"ruma-identifiers-macros 0.17.4 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)",
"ruma-identifiers-validation 0.1.1 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)",
"ruma-serde 0.2.3 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)",
"serde",
"strum",
]
[[package]]
name = "ruma-identifiers"
version = "0.17.4"
source = "git+https://github.com/DevinR528/ruma?branch=unstable-join#424b138d84ccc47c0b212708a54f66bf88f7d57a"
dependencies = [ dependencies = [
"rand", "rand",
"ruma-identifiers-macros 0.17.4 (git+https://github.com/DevinR528/ruma?branch=unstable-join)", "ruma-identifiers-macros",
"ruma-identifiers-validation 0.1.1 (git+https://github.com/DevinR528/ruma?branch=unstable-join)", "ruma-identifiers-validation",
"ruma-serde 0.2.3 (git+https://github.com/DevinR528/ruma?branch=unstable-join)", "ruma-serde",
"serde", "serde",
"strum", "strum",
] ]
@ -1926,18 +1769,7 @@ source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"ruma-identifiers-validation 0.1.1 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-identifiers-validation",
"syn",
]
[[package]]
name = "ruma-identifiers-macros"
version = "0.17.4"
source = "git+https://github.com/DevinR528/ruma?branch=unstable-join#424b138d84ccc47c0b212708a54f66bf88f7d57a"
dependencies = [
"proc-macro2",
"quote",
"ruma-identifiers-validation 0.1.1 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"syn", "syn",
] ]
@ -1950,15 +1782,6 @@ dependencies = [
"strum", "strum",
] ]
[[package]]
name = "ruma-identifiers-validation"
version = "0.1.1"
source = "git+https://github.com/DevinR528/ruma?branch=unstable-join#424b138d84ccc47c0b212708a54f66bf88f7d57a"
dependencies = [
"serde",
"strum",
]
[[package]] [[package]]
name = "ruma-serde" name = "ruma-serde"
version = "0.2.3" version = "0.2.3"
@ -1971,18 +1794,6 @@ dependencies = [
"serde_json", "serde_json",
] ]
[[package]]
name = "ruma-serde"
version = "0.2.3"
source = "git+https://github.com/DevinR528/ruma?branch=unstable-join#424b138d84ccc47c0b212708a54f66bf88f7d57a"
dependencies = [
"form_urlencoded",
"itoa",
"js_int",
"serde",
"serde_json",
]
[[package]] [[package]]
name = "ruma-signatures" name = "ruma-signatures"
version = "0.6.0-dev.1" version = "0.6.0-dev.1"
@ -1990,21 +1801,8 @@ source = "git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a
dependencies = [ dependencies = [
"base64", "base64",
"ring", "ring",
"ruma-identifiers 0.17.4 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-identifiers",
"ruma-serde 0.2.3 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma-serde",
"serde_json",
"untrusted",
]
[[package]]
name = "ruma-signatures"
version = "0.6.0-dev.1"
source = "git+https://github.com/DevinR528/ruma?branch=unstable-join#424b138d84ccc47c0b212708a54f66bf88f7d57a"
dependencies = [
"base64",
"ring",
"ruma-identifiers 0.17.4 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"ruma-serde 0.2.3 (git+https://github.com/DevinR528/ruma?branch=unstable-join)",
"serde_json", "serde_json",
"untrusted", "untrusted",
] ]
@ -2263,7 +2061,7 @@ dependencies = [
"itertools", "itertools",
"js_int", "js_int",
"maplit", "maplit",
"ruma 0.0.1 (git+https://github.com/ruma/ruma?rev=c15382ca41262058302959eac4029ab4a1ea5889)", "ruma",
"serde", "serde",
"serde_json", "serde_json",
"thiserror", "thiserror",

View File

@ -18,8 +18,8 @@ edition = "2018"
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", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"], rev = "aff914050eb297bd82b8aafb12158c88a9e480e1" } ruma = { git = "https://github.com/ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks", "unstable-exhaustive-types"], rev = "c15382ca41262058302959eac4029ab4a1ea5889" }
ruma = { git = "https://github.com/DevinR528/ruma", features = ["rand", "client-api", "federation-api", "unstable-exhaustive-types", "unstable-pre-spec", "unstable-synapse-quirks"], branch = "unstable-join" } # ruma = { git = "https://github.com/DevinR528/ruma", features = ["rand", "client-api", "federation-api", "unstable-exhaustive-types", "unstable-pre-spec", "unstable-synapse-quirks"], branch = "unstable-join" }
# ruma = { path = "../ruma/ruma", features = ["unstable-exhaustive-types", "rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"] } # ruma = { path = "../ruma/ruma", features = ["unstable-exhaustive-types", "rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"] }
# Used when doing state resolution # Used when doing state resolution
@ -73,11 +73,3 @@ required-features = ["conduit_bin"]
[lib] [lib]
name = "conduit" name = "conduit"
path = "src/lib.rs" path = "src/lib.rs"
# [patch."https://github.com/timokoesters/ruma"]
# ruma = { path = "../ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-exhaustive-types", "unstable-pre-spec", "unstable-synapse-quirks"] }
# # ruma = { git = "https://github.com/ruma/ruma", rev = "64b9c646d15a359d62ab464a95176ff94adb2554", features = ["rand", "client-api", "federation-api", "unstable-exhaustive-types", "unstable-pre-spec", "unstable-synapse-quirks"]}
# [patch."https://github.com/ruma/state-res"]
# state-res = { path = "../../state-res", features = ["unstable-pre-spec", "gen-eventid"] }
# # state-res = { git = "https://github.com/ruma/state-res", branch = "timo-spec-comp" }

View File

@ -515,9 +515,7 @@ async fn join_room_by_id_helper(
let mut canon_json_stub: BTreeMap<_, ruma::signatures::CanonicalJsonValue> = let mut canon_json_stub: BTreeMap<_, ruma::signatures::CanonicalJsonValue> =
serde_json::from_value(join_event_stub_value).expect("json Value is canonical JSON"); serde_json::from_value(join_event_stub_value).expect("json Value is canonical JSON");
// We don't leave the event id into the pdu because that's only allowed in v1 or v2 rooms // We don't leave the event id in the pdu because that's only allowed in v1 or v2 rooms
// let join_event_stub = join_event_stub_value.as_object_mut().unwrap();
// join_event_stub.remove("event_id");
canon_json_stub.remove("event_id"); canon_json_stub.remove("event_id");
// In order to create a compatible ref hash (EventID) the `hashes` field needs to be present // In order to create a compatible ref hash (EventID) the `hashes` field needs to be present

View File

@ -405,11 +405,12 @@ impl Rooms {
pub fn get_closest_parent( pub fn get_closest_parent(
&self, &self,
room: &RoomId,
incoming_prev_ids: &[EventId], incoming_prev_ids: &[EventId],
their_state: &BTreeMap<EventId, Arc<StateEvent>>, their_state: &BTreeMap<EventId, Arc<StateEvent>>,
) -> Result<Option<ClosestParent>> { ) -> Result<Option<ClosestParent>> {
match self.pduid_pdu.last()? { match self.pduid_pdu.scan_prefix(room.as_bytes()).last() {
Some(val) Some(Ok(val))
if incoming_prev_ids.contains( if incoming_prev_ids.contains(
&serde_json::from_slice::<PduEvent>(&val.1) &serde_json::from_slice::<PduEvent>(&val.1)
.map_err(|_| { .map_err(|_| {

View File

@ -418,6 +418,7 @@ pub async fn send_transaction_message_route<'a>(
} }
} }
} }
// TODO: For RoomVersion6 we must check that Raw<..> is canonical do we? // TODO: For RoomVersion6 we must check that Raw<..> is canonical do we?
// SPEC: // SPEC:
// Servers MUST strictly enforce the JSON format specified in the appendices. // Servers MUST strictly enforce the JSON format specified in the appendices.
@ -427,42 +428,20 @@ pub async fn send_transaction_message_route<'a>(
// would return a M_BAD_JSON error. // would return a M_BAD_JSON error.
let mut resolved_map = BTreeMap::new(); let mut resolved_map = BTreeMap::new();
for pdu in &body.pdus { for pdu in &body.pdus {
println!("LOOP");
let (event_id, value) = process_incoming_pdu(pdu); let (event_id, value) = process_incoming_pdu(pdu);
let pdu = serde_json::from_value::<PduEvent>(value.clone()) let pdu = serde_json::from_value::<PduEvent>(value.clone())
.expect("all ruma pdus are conduit pdus"); .expect("all ruma pdus are conduit pdus");
let room_id = &pdu.room_id; let room_id = &pdu.room_id;
if value.get("state_key").is_none() { // If we have no idea about this room
if !db.rooms.is_joined(&pdu.sender, &pdu.room_id)? { // TODO: Does a server only send us events that we should know about or
// TODO: auth rules apply to all events, not only those with a state key // when everyone on this server leaves a room can we ignore those events?
log::error!("Unauthorized {}", pdu.kind); if !db.rooms.exists(&pdu.room_id)? {
log::error!("Room does not exist on this server");
resolved_map.insert(event_id, Err("User is not in this room".into())); resolved_map.insert(event_id, Err("Room is unknown to this server".into()));
continue; continue;
} }
// TODO: We should be doing the same get_closest_parent thing here too?
// same as for state events ~100 lines down
let count = db.globals.next_count()?;
let mut pdu_id = pdu.room_id.as_bytes().to_vec();
pdu_id.push(0xff);
pdu_id.extend_from_slice(&count.to_be_bytes());
db.rooms.append_pdu(
&pdu,
&value,
count,
pdu_id.into(),
&db.globals,
&db.account_data,
&db.admin,
)?;
resolved_map.insert(event_id, Ok::<(), String>(()));
continue;
}
let now = std::time::Instant::now();
let get_state_response = match send_request( let get_state_response = match send_request(
&db.globals, &db.globals,
body.body.origin.clone(), body.body.origin.clone(),
@ -482,11 +461,9 @@ pub async fn send_transaction_message_route<'a>(
Err(err) => { Err(err) => {
log::error!("Request failed: {}", err); log::error!("Request failed: {}", err);
resolved_map.insert(event_id, Err(err.to_string())); resolved_map.insert(event_id, Err(err.to_string()));
dbg!(now.elapsed());
continue; continue;
} }
}; };
dbg!(now.elapsed());
let their_current_state = get_state_response let their_current_state = get_state_response
.pdus .pdus
@ -509,40 +486,21 @@ pub async fn send_transaction_message_route<'a>(
if value.get("state_key").is_none() { if value.get("state_key").is_none() {
if !db.rooms.is_joined(&pdu.sender, &pdu.room_id)? { if !db.rooms.is_joined(&pdu.sender, &pdu.room_id)? {
// TODO: auth rules apply to all events, not only those with a state key
log::error!("Sender is not joined {}", pdu.kind); log::error!("Sender is not joined {}", pdu.kind);
resolved_map.insert(event_id, Err("User is not in this room".into())); resolved_map.insert(event_id, Err("User is not in this room".into()));
continue; continue;
} }
// // TODO: We should be doing the same get_closest_parent thing here too?
// // same as for state events ~100 lines down
// let count = db.globals.next_count()?;
// let mut pdu_id = pdu.room_id.as_bytes().to_vec();
// pdu_id.push(0xff);
// pdu_id.extend_from_slice(&count.to_be_bytes());
// db.rooms.append_pdu(
// &pdu,
// &value,
// count,
// pdu_id.into(),
// &db.globals,
// &db.account_data,
// &db.sending,
// )?;
// If the event is older than the last event in pduid_pdu Tree then find the // If the event is older than the last event in pduid_pdu Tree then find the
// closest ancestor we know of and insert after the known ancestor by // closest ancestor we know of and insert after the known ancestor by
// altering the known events pduid to = same roomID + same count bytes + 0x1 // altering the known events pduid to = same roomID + same count bytes + 0x1
// pushing a single byte every time a simple append cannot be done. // pushing a single byte every time a simple append cannot be done.
match db match db
.rooms .rooms
.get_closest_parent(&pdu.prev_events, &their_current_state)? .get_closest_parent(room_id, &pdu.prev_events, &their_current_state)?
{ {
Some(ClosestParent::Append) => { Some(ClosestParent::Append) => {
let count = db.globals.next_count()?; let count = db.globals.next_count()?;
dbg!(&count);
let mut pdu_id = room_id.as_bytes().to_vec(); let mut pdu_id = room_id.as_bytes().to_vec();
pdu_id.push(0xff); pdu_id.push(0xff);
pdu_id.extend_from_slice(&count.to_be_bytes()); pdu_id.extend_from_slice(&count.to_be_bytes());
@ -554,10 +512,12 @@ pub async fn send_transaction_message_route<'a>(
pdu_id.into(), pdu_id.into(),
&db.globals, &db.globals,
&db.account_data, &db.account_data,
&db.sending, &db.admin,
)?; )?;
} }
Some(ClosestParent::Insert(old_count)) => { Some(ClosestParent::Insert(old_count)) => {
println!("INSERT PDU FOUND {}", old_count);
let count = old_count; let count = old_count;
let mut pdu_id = room_id.as_bytes().to_vec(); let mut pdu_id = room_id.as_bytes().to_vec();
pdu_id.push(0xff); pdu_id.push(0xff);
@ -573,7 +533,7 @@ pub async fn send_transaction_message_route<'a>(
pdu_id.into(), pdu_id.into(),
&db.globals, &db.globals,
&db.account_data, &db.account_data,
&db.sending, &db.admin,
)?; )?;
} }
_ => panic!("Not a sequential event or no parents found"), _ => panic!("Not a sequential event or no parents found"),
@ -615,13 +575,13 @@ pub async fn send_transaction_message_route<'a>(
// closest ancestor we know of and insert after the known ancestor by // closest ancestor we know of and insert after the known ancestor by
// altering the known events pduid to = same roomID + same count bytes + 0x1 // altering the known events pduid to = same roomID + same count bytes + 0x1
// pushing a single byte every time a simple append cannot be done. // pushing a single byte every time a simple append cannot be done.
match db match db.rooms.get_closest_parent(
.rooms room_id,
.get_closest_parent(&pdu.prev_events, &their_current_state)? &pdu.prev_events,
{ &their_current_state,
)? {
Some(ClosestParent::Append) => { Some(ClosestParent::Append) => {
let count = db.globals.next_count()?; let count = db.globals.next_count()?;
dbg!(&count);
let mut pdu_id = room_id.as_bytes().to_vec(); let mut pdu_id = room_id.as_bytes().to_vec();
pdu_id.push(0xff); pdu_id.push(0xff);
pdu_id.extend_from_slice(&count.to_be_bytes()); pdu_id.extend_from_slice(&count.to_be_bytes());
@ -633,11 +593,12 @@ pub async fn send_transaction_message_route<'a>(
pdu_id.into(), pdu_id.into(),
&db.globals, &db.globals,
&db.account_data, &db.account_data,
&db.sending, &db.admin,
)?; )?;
} }
Some(ClosestParent::Insert(old_count)) => { Some(ClosestParent::Insert(old_count)) => {
println!("INSERT PDU FOUND {}", old_count); println!("INSERT STATE PDU FOUND {}", old_count);
let count = old_count; let count = old_count;
let mut pdu_id = room_id.as_bytes().to_vec(); let mut pdu_id = room_id.as_bytes().to_vec();
pdu_id.push(0xff); pdu_id.push(0xff);
@ -653,7 +614,7 @@ pub async fn send_transaction_message_route<'a>(
pdu_id.into(), pdu_id.into(),
&db.globals, &db.globals,
&db.account_data, &db.account_data,
&db.sending, &db.admin,
)?; )?;
} }
_ => panic!("Not a sequential event or no parents found"), _ => panic!("Not a sequential event or no parents found"),

View File

@ -94,18 +94,3 @@ pub fn common_elements(
.all(|b| b) .all(|b| b)
})) }))
} }
#[test]
fn sled_tests() {
let db = sled::Config::new().temporary(true).open().unwrap();
db.insert(1_u64.to_be_bytes(), vec![10]).unwrap();
db.insert(2_u64.to_be_bytes(), vec![20]).unwrap();
db.insert(3_u64.to_be_bytes(), vec![30]).unwrap();
let mut key = 1_u64.to_be_bytes().to_vec();
key.push(1);
db.insert(key, vec![40]).unwrap();
println!("{:?}", db.iter().collect::<Result<Vec<_>, _>>().unwrap())
}