mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-29 11:57:32 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c9edb84df | ||
|
|
8144c948cb | ||
|
|
a1c0045367 |
No files matched your search
@@ -56,7 +56,7 @@ repos:
|
|||||||
hooks:
|
hooks:
|
||||||
- id: cargo-clippy
|
- id: cargo-clippy
|
||||||
name: cargo clippy
|
name: cargo clippy
|
||||||
entry: cargo clippy --
|
entry: cargo clippy -- -D warnings
|
||||||
language: system
|
language: system
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
types: [ rust ]
|
types: [ rust ]
|
||||||
|
|||||||
Generated
+30
-63
@@ -485,20 +485,19 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bindgen"
|
name = "bindgen"
|
||||||
version = "0.72.1"
|
version = "0.73.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895"
|
checksum = "787ef8ef523575546b106a58213d6e6b06198a05c2f757258c68a74273670cfa"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cexpr",
|
"cexpr",
|
||||||
"clang-sys",
|
"clang-sys",
|
||||||
"itertools 0.13.0",
|
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"regex",
|
"regex",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"shlex 1.3.0",
|
"shlex",
|
||||||
"syn 2.0.119",
|
"syn 3.0.10",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -684,7 +683,7 @@ dependencies = [
|
|||||||
"find-msvc-tools",
|
"find-msvc-tools",
|
||||||
"jobserver",
|
"jobserver",
|
||||||
"libc",
|
"libc",
|
||||||
"shlex 2.0.1",
|
"shlex",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -874,13 +873,9 @@ dependencies = [
|
|||||||
name = "conduwuit"
|
name = "conduwuit"
|
||||||
version = "26.11.0-rc.1"
|
version = "26.11.0-rc.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aws-lc-rs",
|
|
||||||
"clap",
|
"clap",
|
||||||
"conduwuit_admin",
|
|
||||||
"conduwuit_api",
|
|
||||||
"conduwuit_build_metadata",
|
"conduwuit_build_metadata",
|
||||||
"conduwuit_core",
|
"conduwuit_core",
|
||||||
"conduwuit_database",
|
|
||||||
"conduwuit_macros",
|
"conduwuit_macros",
|
||||||
"conduwuit_router",
|
"conduwuit_router",
|
||||||
"conduwuit_service",
|
"conduwuit_service",
|
||||||
@@ -888,7 +883,6 @@ dependencies = [
|
|||||||
"const-str",
|
"const-str",
|
||||||
"ctor",
|
"ctor",
|
||||||
"dtor",
|
"dtor",
|
||||||
"log",
|
|
||||||
"opentelemetry",
|
"opentelemetry",
|
||||||
"opentelemetry-otlp",
|
"opentelemetry-otlp",
|
||||||
"opentelemetry-prometheus",
|
"opentelemetry-prometheus",
|
||||||
@@ -896,13 +890,10 @@ dependencies = [
|
|||||||
"opentelemetry_sdk",
|
"opentelemetry_sdk",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"prometheus",
|
"prometheus",
|
||||||
"reqwest 0.13.5",
|
|
||||||
"rustls",
|
"rustls",
|
||||||
"sentry",
|
"sentry",
|
||||||
"sentry-tower",
|
|
||||||
"sentry-tracing",
|
"sentry-tracing",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-metrics",
|
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-flame",
|
"tracing-flame",
|
||||||
"tracing-journald",
|
"tracing-journald",
|
||||||
@@ -1143,6 +1134,7 @@ dependencies = [
|
|||||||
"p256 0.14.0",
|
"p256 0.14.0",
|
||||||
"rand 0.10.4",
|
"rand 0.10.4",
|
||||||
"regex",
|
"regex",
|
||||||
|
"reqwest 0.12.28",
|
||||||
"reqwest 0.13.5",
|
"reqwest 0.13.5",
|
||||||
"resolvematrix",
|
"resolvematrix",
|
||||||
"ruma",
|
"ruma",
|
||||||
@@ -2720,10 +2712,10 @@ dependencies = [
|
|||||||
"hyper",
|
"hyper",
|
||||||
"hyper-util",
|
"hyper-util",
|
||||||
"rustls",
|
"rustls",
|
||||||
|
"rustls-native-certs",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-rustls",
|
"tokio-rustls",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
"webpki-roots",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2997,15 +2989,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "itertools"
|
|
||||||
version = "0.13.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
|
|
||||||
dependencies = [
|
|
||||||
"either",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itertools"
|
name = "itertools"
|
||||||
version = "0.14.0"
|
version = "0.14.0"
|
||||||
@@ -3276,9 +3259,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libz-sys"
|
name = "libz-sys"
|
||||||
version = "1.1.29"
|
version = "1.1.32"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "85bc9657773828b90eeb625adff10eeac83cc21bbfd8e23a03eaa8a33c9e28d9"
|
checksum = "69965d2409bff8c8cea3829009fff66a86f05a0570656552ef70f616e8e4bd85"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
@@ -4197,12 +4180,6 @@ dependencies = [
|
|||||||
"phc",
|
"phc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "paste"
|
|
||||||
version = "1.0.15"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pear"
|
name = "pear"
|
||||||
version = "0.2.9"
|
version = "0.2.9"
|
||||||
@@ -4866,8 +4843,8 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"quinn",
|
|
||||||
"rustls",
|
"rustls",
|
||||||
|
"rustls-native-certs",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -4882,7 +4859,6 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
"webpki-roots",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -4938,9 +4914,9 @@ checksum = "1e061d1b48cb8d38042de4ae0a7a6401009d6143dc80d2e2d6f31f0bdd6470c7"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "resolvematrix"
|
name = "resolvematrix"
|
||||||
version = "1.6.0"
|
version = "1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8c7ff53b0a73edb760d7b851fa63c65070f0c05532122ef25e0feb13a7fbb3c7"
|
checksum = "39a1efc3c55274528f8b1a916eb0edf5c40a8364b4899fbc1283a57c8d0024db"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cache_control",
|
"cache_control",
|
||||||
"hickory-resolver",
|
"hickory-resolver",
|
||||||
@@ -5221,8 +5197,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-librocksdb-sys"
|
name = "rust-librocksdb-sys"
|
||||||
version = "0.45.1+11.1.1"
|
version = "0.49.0+11.12.0"
|
||||||
source = "git+https://forgejo.ellis.link/continuwuation/rust-rocksdb-zaidoon1?rev=0a25ff92f7c09b55eec496b9c192c7d5136ab2b8#0a25ff92f7c09b55eec496b9c192c7d5136ab2b8"
|
source = "git+https://forgejo.ellis.link/continuwuation/rust-rocksdb-zaidoon1?rev=85ded20348e3dab902c239967075795e9c6d101b#85ded20348e3dab902c239967075795e9c6d101b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
"bzip2-sys",
|
"bzip2-sys",
|
||||||
@@ -5232,14 +5208,15 @@ dependencies = [
|
|||||||
"libz-sys",
|
"libz-sys",
|
||||||
"lz4-sys",
|
"lz4-sys",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
|
"rustflags",
|
||||||
"tikv-jemalloc-sys",
|
"tikv-jemalloc-sys",
|
||||||
"zstd-sys",
|
"zstd-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-rocksdb"
|
name = "rust-rocksdb"
|
||||||
version = "0.49.1"
|
version = "0.54.0"
|
||||||
source = "git+https://forgejo.ellis.link/continuwuation/rust-rocksdb-zaidoon1?rev=0a25ff92f7c09b55eec496b9c192c7d5136ab2b8#0a25ff92f7c09b55eec496b9c192c7d5136ab2b8"
|
source = "git+https://forgejo.ellis.link/continuwuation/rust-rocksdb-zaidoon1?rev=85ded20348e3dab902c239967075795e9c6d101b#85ded20348e3dab902c239967075795e9c6d101b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
@@ -5267,6 +5244,12 @@ dependencies = [
|
|||||||
"semver",
|
"semver",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustflags"
|
||||||
|
version = "0.1.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a39e0e9135d7a7208ee80aa4e3e4b88f0f5ad7be92153ed70686c38a03db2e63"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustix"
|
name = "rustix"
|
||||||
version = "1.1.6"
|
version = "1.1.6"
|
||||||
@@ -5659,7 +5642,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "969cde0349344dbbf58b5f9badbfb8f806db13969364eb8007c057ef687007d9"
|
checksum = "969cde0349344dbbf58b5f9badbfb8f806db13969364eb8007c057ef687007d9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"annotate-snippets",
|
"annotate-snippets",
|
||||||
"base64 0.23.1",
|
"base64 0.22.1",
|
||||||
"encoding_rs_io",
|
"encoding_rs_io",
|
||||||
"granit-parser",
|
"granit-parser",
|
||||||
"nohash-hasher",
|
"nohash-hasher",
|
||||||
@@ -5894,12 +5877,6 @@ dependencies = [
|
|||||||
"lazy_static",
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "shlex"
|
|
||||||
version = "1.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shlex"
|
name = "shlex"
|
||||||
version = "2.0.1"
|
version = "2.0.1"
|
||||||
@@ -6259,18 +6236,17 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tikv-jemalloc-ctl"
|
name = "tikv-jemalloc-ctl"
|
||||||
version = "0.6.1"
|
version = "0.7.0"
|
||||||
source = "git+https://forgejo.ellis.link/continuwuation/jemallocator?rev=df86ff89d4b1e223b9f7d2dd2fbb7f202da7f554#df86ff89d4b1e223b9f7d2dd2fbb7f202da7f554"
|
source = "git+https://forgejo.ellis.link/continuwuation/jemallocator?rev=46e7821917b06636cdb5b203d312799970eaea92#46e7821917b06636cdb5b203d312799970eaea92"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"paste",
|
|
||||||
"tikv-jemalloc-sys",
|
"tikv-jemalloc-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tikv-jemalloc-sys"
|
name = "tikv-jemalloc-sys"
|
||||||
version = "0.6.1+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7"
|
version = "0.7.0+5.4.0-0-g7a34f18502e7b222724097cdcd499b437d189acc"
|
||||||
source = "git+https://forgejo.ellis.link/continuwuation/jemallocator?rev=df86ff89d4b1e223b9f7d2dd2fbb7f202da7f554#df86ff89d4b1e223b9f7d2dd2fbb7f202da7f554"
|
source = "git+https://forgejo.ellis.link/continuwuation/jemallocator?rev=46e7821917b06636cdb5b203d312799970eaea92#46e7821917b06636cdb5b203d312799970eaea92"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -6278,8 +6254,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tikv-jemallocator"
|
name = "tikv-jemallocator"
|
||||||
version = "0.6.1"
|
version = "0.7.0"
|
||||||
source = "git+https://forgejo.ellis.link/continuwuation/jemallocator?rev=df86ff89d4b1e223b9f7d2dd2fbb7f202da7f554#df86ff89d4b1e223b9f7d2dd2fbb7f202da7f554"
|
source = "git+https://forgejo.ellis.link/continuwuation/jemallocator?rev=46e7821917b06636cdb5b203d312799970eaea92#46e7821917b06636cdb5b203d312799970eaea92"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"tikv-jemalloc-sys",
|
"tikv-jemalloc-sys",
|
||||||
@@ -7137,15 +7113,6 @@ dependencies = [
|
|||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "webpki-roots"
|
|
||||||
version = "1.0.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f5f280bbb2b287bc8e7de7e3852945a0ff50d1bbcb5ed42b6c7a568c546df171"
|
|
||||||
dependencies = [
|
|
||||||
"rustls-pki-types",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "weezl"
|
name = "weezl"
|
||||||
version = "0.1.12"
|
version = "0.1.12"
|
||||||
|
|||||||
+16
-5
@@ -166,6 +166,15 @@ features = [
|
|||||||
"form",
|
"form",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Needed for as long as openidconnect is on an outdated reqwest
|
||||||
|
[workspace.dependencies.reqwest_0_12]
|
||||||
|
package = "reqwest"
|
||||||
|
version = "0.12"
|
||||||
|
default-features = false
|
||||||
|
features = [
|
||||||
|
"rustls-tls-native-roots-no-provider",
|
||||||
|
]
|
||||||
|
|
||||||
[workspace.dependencies.serde]
|
[workspace.dependencies.serde]
|
||||||
version = "1.0.229"
|
version = "1.0.229"
|
||||||
default-features = false
|
default-features = false
|
||||||
@@ -394,7 +403,7 @@ features = [
|
|||||||
|
|
||||||
[workspace.dependencies.rust-rocksdb]
|
[workspace.dependencies.rust-rocksdb]
|
||||||
git = "https://forgejo.ellis.link/continuwuation/rust-rocksdb-zaidoon1"
|
git = "https://forgejo.ellis.link/continuwuation/rust-rocksdb-zaidoon1"
|
||||||
rev = "0a25ff92f7c09b55eec496b9c192c7d5136ab2b8"
|
rev = "85ded20348e3dab902c239967075795e9c6d101b"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = [
|
features = [
|
||||||
"multi-threaded-cf",
|
"multi-threaded-cf",
|
||||||
@@ -414,6 +423,8 @@ default-features = false
|
|||||||
|
|
||||||
[workspace.dependencies.openidconnect]
|
[workspace.dependencies.openidconnect]
|
||||||
version = "4.1.0"
|
version = "4.1.0"
|
||||||
|
default-features = false
|
||||||
|
features = ["reqwest"]
|
||||||
|
|
||||||
# optional opentelemetry, performance measurements, flamegraphs, etc for performance measurements and monitoring
|
# optional opentelemetry, performance measurements, flamegraphs, etc for performance measurements and monitoring
|
||||||
[workspace.dependencies.opentelemetry]
|
[workspace.dependencies.opentelemetry]
|
||||||
@@ -476,7 +487,7 @@ version = "0.49.5"
|
|||||||
# jemalloc usage
|
# jemalloc usage
|
||||||
[workspace.dependencies.tikv-jemalloc-sys]
|
[workspace.dependencies.tikv-jemalloc-sys]
|
||||||
git = "https://forgejo.ellis.link/continuwuation/jemallocator"
|
git = "https://forgejo.ellis.link/continuwuation/jemallocator"
|
||||||
rev = "df86ff89d4b1e223b9f7d2dd2fbb7f202da7f554"
|
rev = "46e7821917b06636cdb5b203d312799970eaea92"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = [
|
features = [
|
||||||
"background_threads_runtime_support",
|
"background_threads_runtime_support",
|
||||||
@@ -484,7 +495,7 @@ features = [
|
|||||||
]
|
]
|
||||||
[workspace.dependencies.tikv-jemallocator]
|
[workspace.dependencies.tikv-jemallocator]
|
||||||
git = "https://forgejo.ellis.link/continuwuation/jemallocator"
|
git = "https://forgejo.ellis.link/continuwuation/jemallocator"
|
||||||
rev = "df86ff89d4b1e223b9f7d2dd2fbb7f202da7f554"
|
rev = "46e7821917b06636cdb5b203d312799970eaea92"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = [
|
features = [
|
||||||
"background_threads_runtime_support",
|
"background_threads_runtime_support",
|
||||||
@@ -492,7 +503,7 @@ features = [
|
|||||||
]
|
]
|
||||||
[workspace.dependencies.tikv-jemalloc-ctl]
|
[workspace.dependencies.tikv-jemalloc-ctl]
|
||||||
git = "https://forgejo.ellis.link/continuwuation/jemallocator"
|
git = "https://forgejo.ellis.link/continuwuation/jemallocator"
|
||||||
rev = "df86ff89d4b1e223b9f7d2dd2fbb7f202da7f554"
|
rev = "46e7821917b06636cdb5b203d312799970eaea92"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["use_std"]
|
features = ["use_std"]
|
||||||
|
|
||||||
@@ -584,7 +595,7 @@ version = "0.3.18"
|
|||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
|
|
||||||
[workspace.dependencies.resolvematrix]
|
[workspace.dependencies.resolvematrix]
|
||||||
version = "1.6.0"
|
version = "1.5.0"
|
||||||
features = ["unstable-msc4188"]
|
features = ["unstable-msc4188"]
|
||||||
|
|
||||||
[workspace.dependencies.serde_urlencoded]
|
[workspace.dependencies.serde_urlencoded]
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
Fixed read receipts for all but one of a user's threads not being sent over federation. Contributed by @eleboucher.
|
|
||||||
@@ -813,6 +813,18 @@
|
|||||||
# env: CONTINUWUITY_FORGET_FORCED_UPON_LEAVE
|
# env: CONTINUWUITY_FORGET_FORCED_UPON_LEAVE
|
||||||
#forget_forced_upon_leave = false
|
#forget_forced_upon_leave = false
|
||||||
|
|
||||||
|
# Set this to true to require authentication when looking up user profiles
|
||||||
|
# through this server.
|
||||||
|
#
|
||||||
|
# By default this is false, allowing tools such as matrix.to to access
|
||||||
|
# profiles of users on this server and on other servers.
|
||||||
|
# Setting this to true will block those tools, and may block automated
|
||||||
|
# crawlers from scraping users' profiles, although it will not block
|
||||||
|
# other homeservers from accessing users' profiles.
|
||||||
|
#
|
||||||
|
# env: CONTINUWUITY_REQUIRE_AUTH_FOR_PROFILE_REQUESTS
|
||||||
|
#require_auth_for_profile_requests = false
|
||||||
|
|
||||||
# Set this to true to require authentication to create a rendezvous
|
# Set this to true to require authentication to create a rendezvous
|
||||||
# session. Rendezvous sessions are used for QR code login.
|
# session. Rendezvous sessions are used for QR code login.
|
||||||
#
|
#
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@
|
|||||||
target:
|
target:
|
||||||
target.fromToolchainName {
|
target.fromToolchainName {
|
||||||
name = (lib.importTOML "${inputs.self}/rust-toolchain.toml").toolchain.channel;
|
name = (lib.importTOML "${inputs.self}/rust-toolchain.toml").toolchain.channel;
|
||||||
sha256 = "sha256-MFHoWVcPZKjFrLnQnodCXbUsfZcofGfo9tV9fTTvklg=";
|
sha256 = "sha256-W3A3rtdDaQW5yOvFr5JVTfngRUCKKUqPCPIW/3aH0nM=";
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|||||||
Generated
+23
-21
@@ -11,7 +11,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rspress/core": "^2.0.0",
|
"@rspress/core": "^2.0.0",
|
||||||
"@rspress/plugin-client-redirects": "^2.0.0",
|
"@rspress/plugin-client-redirects": "^2.0.0",
|
||||||
"@types/node": "^26.6.6",
|
"@types/node": "^26.6.7",
|
||||||
"typescript": "^7.0.0"
|
"typescript": "^7.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -458,9 +458,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspress/core": {
|
"node_modules/@rspress/core": {
|
||||||
"version": "2.1.4",
|
"version": "2.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/core/-/core-2.1.5.tgz",
|
||||||
"integrity": "sha512-7OmP7ABDgQLSpVfpBHfpjqu4H3PGBGMyhLxF1crPQ48Q6MIWAVu77nw7cONn8AZa9GoVq0N/DoE3GEtgZzlu6w==",
|
"integrity": "sha512-kzTqrfJ4UiW+RLLHLunoW/rET5Vjb6Qz4YjhEhiWEp4HYM+KxLVhfyYB5aL8af9+mdnwiTaqlu1s+BZGrMD2zw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -468,27 +468,29 @@
|
|||||||
"@mdx-js/react": "^3.1.1",
|
"@mdx-js/react": "^3.1.1",
|
||||||
"@rsbuild/core": "^2.3.3",
|
"@rsbuild/core": "^2.3.3",
|
||||||
"@rsbuild/plugin-react": "~2.1.1",
|
"@rsbuild/plugin-react": "~2.1.1",
|
||||||
"@rspress/shared": "2.1.4",
|
"@rspress/shared": "2.1.5",
|
||||||
"@shikijs/rehype": "^4.2.0",
|
"@shikijs/rehype": "^4.2.0",
|
||||||
"@shikijs/transformers": "^4.2.0",
|
"@shikijs/transformers": "^4.2.0",
|
||||||
"@types/mdast": "^4.0.4",
|
"@types/mdast": "^4.0.4",
|
||||||
"@types/react": "^19.3.0",
|
"@types/react": "^19.3.0",
|
||||||
"@unhead/react": "^2.1.17",
|
"@unhead/react": "^2.1.18",
|
||||||
"body-scroll-lock": "4.0.0-beta.0",
|
"body-scroll-lock": "4.0.0-beta.0",
|
||||||
"clsx": "2.1.1",
|
"clsx": "2.1.1",
|
||||||
"copy-to-clipboard": "^3.3.3",
|
"copy-to-clipboard": "^3.3.3",
|
||||||
"flexsearch": "0.8.212",
|
"flexsearch": "0.8.212",
|
||||||
"hast-util-heading-rank": "^3.0.0",
|
"hast-util-heading-rank": "^3.0.0",
|
||||||
"hast-util-to-jsx-runtime": "^2.3.7",
|
"hast-util-to-jsx-runtime": "^2.3.7",
|
||||||
|
"mdast-util-gfm": "^3.1.0",
|
||||||
"mdast-util-mdx": "^3.0.0",
|
"mdast-util-mdx": "^3.0.0",
|
||||||
"mdast-util-mdxjs-esm": "^2.0.1",
|
"mdast-util-mdxjs-esm": "^2.0.1",
|
||||||
|
"mdast-util-to-markdown": "^2.1.2",
|
||||||
"medium-zoom": "1.1.2",
|
"medium-zoom": "1.1.2",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"react": "^19.3.1",
|
"react": "^19.3.1",
|
||||||
"react-dom": "^19.3.1",
|
"react-dom": "^19.3.1",
|
||||||
"react-lazy-with-preload": "^2.2.1",
|
"react-lazy-with-preload": "^2.2.1",
|
||||||
"react-render-to-markdown": "19.1.0",
|
"react-render-to-markdown": "19.2.0",
|
||||||
"react-router-dom": "^7.18.5",
|
"react-router-dom": "^7.18.6",
|
||||||
"rehype-external-links": "^3.0.0",
|
"rehype-external-links": "^3.0.0",
|
||||||
"rehype-raw": "^7.0.0",
|
"rehype-raw": "^7.0.0",
|
||||||
"remark-cjk-friendly": "^2.3.4",
|
"remark-cjk-friendly": "^2.3.4",
|
||||||
@@ -512,9 +514,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspress/plugin-client-redirects": {
|
"node_modules/@rspress/plugin-client-redirects": {
|
||||||
"version": "2.1.4",
|
"version": "2.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/plugin-client-redirects/-/plugin-client-redirects-2.1.5.tgz",
|
||||||
"integrity": "sha512-6/g+Mr8lslqiFzlMBouex8TLm6PlQK6cmZ71Yfv82+Uxcrb+LaFAFiPbq2G7gToXBQUoECM4D/7nSLAfeOhnEQ==",
|
"integrity": "sha512-vqAi7ynOgVsuwJi7cXwWEF5UgoNhXqGOyBfQubeZHZKWRtdNHRU42P9rG9DZLTss2dZUiDKlVrM2/vNY40t5hw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -525,16 +527,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rspress/shared": {
|
"node_modules/@rspress/shared": {
|
||||||
"version": "2.1.4",
|
"version": "2.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/@rspress/shared/-/shared-2.1.5.tgz",
|
||||||
"integrity": "sha512-SuQyVKn9xcQwkzfl+4bPBzX10gxbhCs9UupqSoPtxvyr9pMgSbXnlo3gxTPZXLzk5HUqZZ6tlIju25PVCEtYWA==",
|
"integrity": "sha512-XXxegxRZ7VPADS2veN9FTNmmLlA65ieydKH0tOhOZbMJC4OJpKbr/d/JS2jxxAO4u+ZmZxbDyEEir83NQHLKIw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rsbuild/core": "^2.3.3",
|
"@rsbuild/core": "^2.3.3",
|
||||||
"@shikijs/rehype": "^4.2.0",
|
"@shikijs/rehype": "^4.2.0",
|
||||||
"@types/react": "^19.3.0",
|
"@types/react": "^19.3.0",
|
||||||
"mdast-util-mdx-jsx": "^3.2.1",
|
"mdast-util-mdx-jsx": "^3.2.2",
|
||||||
"unified": "^11.0.5"
|
"unified": "^11.0.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -758,9 +760,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "26.6.10",
|
"version": "26.6.11",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.10.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.11.tgz",
|
||||||
"integrity": "sha512-WJuPHoGB8WNQuTksNF7SOQpnH02PXeDYz4iueWbBT6/hTWnShY5F3T/hoJA3fY9+uYReDZ7pyTKKx83jQa7aGg==",
|
"integrity": "sha512-uUyQ2XLEz+EXh34lmS3GhKrkqn/8FU7KUiKRpk347At2bmnMVWss45yz8b4FG/tUtmV1tV/+TVkITItPROyeeQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -3318,9 +3320,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/react-render-to-markdown": {
|
"node_modules/react-render-to-markdown": {
|
||||||
"version": "19.1.0",
|
"version": "19.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-render-to-markdown/-/react-render-to-markdown-19.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-render-to-markdown/-/react-render-to-markdown-19.2.0.tgz",
|
||||||
"integrity": "sha512-dF9b3tO41ezqdmHP8X92kbHbMexJ6iC7iHw4ykC8fwiO7DgpFc9PhMoKlI+BcPzRxGcWgQSdrixVB9RykhjJpQ==",
|
"integrity": "sha512-hVF80DyFXazwW8vuUaptMwnW9ZZHMRrLE3WE36U3Iz1M6pPrFbtE8yYcTq8CYRBVn7YdagJUR/2ik3qJD2Rlvg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
-46
@@ -1,46 +0,0 @@
|
|||||||
#-------------------------------------------------------------------------------#
|
|
||||||
# Qodana analysis is configured by qodana.yaml file #
|
|
||||||
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
|
|
||||||
#-------------------------------------------------------------------------------#
|
|
||||||
|
|
||||||
#################################################################################
|
|
||||||
# WARNING: Do not store sensitive information in this file, #
|
|
||||||
# as its contents will be included in the Qodana report. #
|
|
||||||
#################################################################################
|
|
||||||
version: "1.0"
|
|
||||||
|
|
||||||
#Specify inspection profile for code analysis
|
|
||||||
profile:
|
|
||||||
name: qodana.starter
|
|
||||||
|
|
||||||
#Enable inspections
|
|
||||||
#include:
|
|
||||||
# - name: <SomeEnabledInspectionId>
|
|
||||||
|
|
||||||
#Disable inspections
|
|
||||||
#exclude:
|
|
||||||
# - name: <SomeDisabledInspectionId>
|
|
||||||
# paths:
|
|
||||||
# - <path/where/not/run/inspection>
|
|
||||||
|
|
||||||
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
|
|
||||||
#bootstrap: sh ./prepare-qodana.sh
|
|
||||||
|
|
||||||
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
|
|
||||||
#plugins:
|
|
||||||
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
|
|
||||||
|
|
||||||
# Quality gate. Will fail the CI/CD pipeline if any condition is not met
|
|
||||||
# severityThresholds - configures maximum thresholds for different problem severities
|
|
||||||
# testCoverageThresholds - configures minimum code coverage on a whole project and newly added code
|
|
||||||
# Code Coverage is available in Ultimate and Ultimate Plus plans
|
|
||||||
#failureConditions:
|
|
||||||
# severityThresholds:
|
|
||||||
# any: 15
|
|
||||||
# critical: 5
|
|
||||||
# testCoverageThresholds:
|
|
||||||
# fresh: 70
|
|
||||||
# total: 50
|
|
||||||
|
|
||||||
#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
|
|
||||||
linter: jetbrains/qodana-<linter>:2026.2
|
|
||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
[toolchain]
|
[toolchain]
|
||||||
profile = "minimal"
|
profile = "minimal"
|
||||||
channel = "1.100.0"
|
channel = "1.100.1"
|
||||||
components = [
|
components = [
|
||||||
# For rust-analyzer
|
# For rust-analyzer
|
||||||
"rust-src",
|
"rust-src",
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ pub(crate) async fn get_profile_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_profile::v3::Request>,
|
body: Ruma<get_profile::v3::Request>,
|
||||||
) -> Result<get_profile::v3::Response> {
|
) -> Result<get_profile::v3::Response> {
|
||||||
if body.identity.is_none() {
|
if services.config.require_auth_for_profile_requests && body.identity.is_none() {
|
||||||
return Err!(Request(Unauthorized(
|
return Err!(Request(Unauthorized(
|
||||||
"This server requires authentication to access user profiles."
|
"This server requires authentication to access user profiles."
|
||||||
)));
|
)));
|
||||||
@@ -46,7 +46,7 @@ pub(crate) async fn get_profile_field_route(
|
|||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<get_profile_field::v3::Request>,
|
body: Ruma<get_profile_field::v3::Request>,
|
||||||
) -> Result<get_profile_field::v3::Response> {
|
) -> Result<get_profile_field::v3::Response> {
|
||||||
if body.identity.is_none() {
|
if services.config.require_auth_for_profile_requests && body.identity.is_none() {
|
||||||
return Err!(Request(Unauthorized(
|
return Err!(Request(Unauthorized(
|
||||||
"This server requires authentication to access user profiles."
|
"This server requires authentication to access user profiles."
|
||||||
)));
|
)));
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use service::Services;
|
|||||||
|
|
||||||
use crate::{Ruma, router::ClientIdentity};
|
use crate::{Ruma, router::ClientIdentity};
|
||||||
|
|
||||||
/// `GET /_matrix/client/unstable/io.element.msc4388/rendezvous`
|
/// `GET /_matrix/client/msc4388/io.element.msc4388/rendezvous`
|
||||||
pub(crate) async fn discover_rendezvous_route(
|
pub(crate) async fn discover_rendezvous_route(
|
||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<discover_rendezvous::msc4388::Request>,
|
body: Ruma<discover_rendezvous::msc4388::Request>,
|
||||||
@@ -20,7 +20,7 @@ pub(crate) async fn discover_rendezvous_route(
|
|||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `POST /_matrix/client/unstable/io.element.msc4388/rendezvous`
|
/// `POST /_matrix/client/msc4388/io.element.msc4388/rendezvous/`
|
||||||
pub(crate) async fn create_rendezvous_session_route(
|
pub(crate) async fn create_rendezvous_session_route(
|
||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<create_rendezvous_session::msc4388::Request>,
|
body: Ruma<create_rendezvous_session::msc4388::Request>,
|
||||||
@@ -32,7 +32,7 @@ pub(crate) async fn create_rendezvous_session_route(
|
|||||||
services.rendezvous.create_session(body.data.clone())
|
services.rendezvous.create_session(body.data.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `PUT /_matrix/client/unstable/io.element.msc4388/rendezvous/{id}/{txn_id}`
|
/// `PUT /_matrix/client/msc4388/io.element.msc4388/rendezvous/{id}/{txn_id}`
|
||||||
pub(crate) async fn update_rendezvous_session_route(
|
pub(crate) async fn update_rendezvous_session_route(
|
||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<update_rendezvous_session::msc4388::Request>,
|
body: Ruma<update_rendezvous_session::msc4388::Request>,
|
||||||
@@ -45,30 +45,16 @@ pub(crate) async fn update_rendezvous_session_route(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `GET /_matrix/client/unstable/io.element.msc4388/rendezvous/{id}`
|
/// `GET /_matrix/client/msc4388/io.element.msc4388/rendezvous/{id}`
|
||||||
pub(crate) async fn get_rendezvous_session_route(
|
pub(crate) async fn get_rendezvous_session_route(
|
||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
headers: HeaderMap,
|
headers: HeaderMap,
|
||||||
body: Ruma<get_rendezvous_session::msc4388::Request>,
|
body: Ruma<get_rendezvous_session::msc4388::Request>,
|
||||||
) -> Result<get_rendezvous_session::msc4388::Response> {
|
) -> Result<get_rendezvous_session::msc4388::Response> {
|
||||||
let is_navigation_mode = headers
|
if let Some(mode) = headers.get("Sec-Fetch-Mode")
|
||||||
.get_all("Sec-Fetch-Mode")
|
&& let Ok(mode) = mode.to_str()
|
||||||
.iter()
|
&& mode == "navigate"
|
||||||
.filter_map(|v| v.to_str().ok())
|
{
|
||||||
.any(|mode| {
|
|
||||||
mode.eq_ignore_ascii_case("navigate") || mode.eq_ignore_ascii_case("nested-navigate")
|
|
||||||
});
|
|
||||||
let is_navigation_dest = headers
|
|
||||||
.get_all("Sec-Fetch-Dest")
|
|
||||||
.iter()
|
|
||||||
.filter_map(|v| v.to_str().ok())
|
|
||||||
.any(|dest| {
|
|
||||||
matches!(
|
|
||||||
dest.to_ascii_lowercase().as_str(),
|
|
||||||
"document" | "iframe" | "frame" | "object" | "embed" | "fencedframe"
|
|
||||||
)
|
|
||||||
});
|
|
||||||
if is_navigation_mode || is_navigation_dest {
|
|
||||||
return Err!(Request(Forbidden(
|
return Err!(Request(Forbidden(
|
||||||
"Rendezvous sessions do not accept browser navigation requests."
|
"Rendezvous sessions do not accept browser navigation requests."
|
||||||
)));
|
)));
|
||||||
@@ -77,7 +63,7 @@ pub(crate) async fn get_rendezvous_session_route(
|
|||||||
services.rendezvous.get_session(&body.id)
|
services.rendezvous.get_session(&body.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `DELETE /_matrix/client/unstable/io.element.msc4388/rendezvous/{id}`
|
/// `DELETE /_matrix/client/msc4388/io.element.msc4388/rendezvous/{id}`
|
||||||
pub(crate) async fn delete_rendezvous_session_route(
|
pub(crate) async fn delete_rendezvous_session_route(
|
||||||
State(services): State<crate::State>,
|
State(services): State<crate::State>,
|
||||||
body: Ruma<delete_rendezvous_session::msc4388::Request>,
|
body: Ruma<delete_rendezvous_session::msc4388::Request>,
|
||||||
|
|||||||
+5
-17
@@ -191,23 +191,11 @@ pub fn build(router: Router<State>, state: State) -> Router<State> {
|
|||||||
.ruma_route(&client::get_rtc_transports)
|
.ruma_route(&client::get_rtc_transports)
|
||||||
.ruma_route(&client::get_rtc_transports_unstable)
|
.ruma_route(&client::get_rtc_transports_unstable)
|
||||||
.ruma_route(&client::room_initial_sync_route)
|
.ruma_route(&client::room_initial_sync_route)
|
||||||
.merge(
|
.ruma_route(&client::discover_rendezvous_route)
|
||||||
Router::new()
|
.ruma_route(&client::create_rendezvous_session_route)
|
||||||
.ruma_route(&client::discover_rendezvous_route)
|
.ruma_route(&client::update_rendezvous_session_route)
|
||||||
.ruma_route(&client::create_rendezvous_session_route)
|
.ruma_route(&client::get_rendezvous_session_route)
|
||||||
.ruma_route(&client::update_rendezvous_session_route)
|
.ruma_route(&client::delete_rendezvous_session_route)
|
||||||
.ruma_route(&client::get_rendezvous_session_route)
|
|
||||||
.ruma_route(&client::delete_rendezvous_session_route)
|
|
||||||
.layer(axum::middleware::map_response(
|
|
||||||
async |mut response: axum::response::Response| {
|
|
||||||
response.headers_mut().insert(
|
|
||||||
http::header::CACHE_CONTROL,
|
|
||||||
http::HeaderValue::from_static("no-store"),
|
|
||||||
);
|
|
||||||
response
|
|
||||||
},
|
|
||||||
)),
|
|
||||||
)
|
|
||||||
.ruma_route(&client::get_authorization_server_metadata_route)
|
.ruma_route(&client::get_authorization_server_metadata_route)
|
||||||
.merge(client::oauth::router(state))
|
.merge(client::oauth::router(state))
|
||||||
.route("/_continuwuity/server_version", get(client::continuwuity_server_version))
|
.route("/_continuwuity/server_version", get(client::continuwuity_server_version))
|
||||||
|
|||||||
+3
-17
@@ -11,11 +11,7 @@ use axum::{
|
|||||||
use conduwuit::{Error, Result, err, error};
|
use conduwuit::{Error, Result, err, error};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonObject,
|
CanonicalJsonObject,
|
||||||
api::{
|
api::{IncomingRequest, IncomingRequestExt, auth_scheme::AuthScheme},
|
||||||
IncomingRequest, IncomingRequestExt,
|
|
||||||
auth_scheme::AuthScheme,
|
|
||||||
error::{DeserializationError, FromHttpRequestError},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
@@ -118,18 +114,8 @@ where
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Deserialize the body
|
// Deserialize the body
|
||||||
let body_is_empty = body.is_empty();
|
let body = R::try_from_http_request(request, &borrowed_path)
|
||||||
let body = R::try_from_http_request(request, &borrowed_path).map_err(|e| match e {
|
.map_err(|e| err!(Request(BadJson(debug_warn!("{e}")))))?;
|
||||||
| FromHttpRequestError::Deserialization(DeserializationError::Json(ref json_err))
|
|
||||||
if body_is_empty || json_err.is_syntax() || json_err.is_eof() =>
|
|
||||||
err!(Request(NotJson(debug_warn!("{e}")))),
|
|
||||||
| FromHttpRequestError::Deserialization(DeserializationError::Utf8(_)) =>
|
|
||||||
err!(Request(NotJson(debug_warn!("{e}")))),
|
|
||||||
| FromHttpRequestError::Deserialization(
|
|
||||||
DeserializationError::Ident(_) | DeserializationError::Query(_),
|
|
||||||
) => err!(Request(InvalidParam(debug_warn!("{e}")))),
|
|
||||||
| _ => err!(Request(BadJson(debug_warn!("{e}")))),
|
|
||||||
})?;
|
|
||||||
|
|
||||||
Ok(Self { body, json_body, identity })
|
Ok(Self { body, json_body, identity })
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-24
@@ -194,10 +194,6 @@ impl CheckAuth for AccessTokenOptional {
|
|||||||
authentication: Self::Output,
|
authentication: Self::Output,
|
||||||
query: AuthQueryParams,
|
query: AuthQueryParams,
|
||||||
) -> Result<Self::Identity> {
|
) -> Result<Self::Identity> {
|
||||||
if R::RATE_LIMITED && is_rendezvous_create_route(TypeId::of::<R>()) {
|
|
||||||
services.rendezvous.check_create_ratelimit(request_ip)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(authentication) = authentication {
|
if let Some(authentication) = authentication {
|
||||||
check_access_token(
|
check_access_token(
|
||||||
services,
|
services,
|
||||||
@@ -282,11 +278,6 @@ impl CheckAuth for NoAccessToken {
|
|||||||
err!(Request(Unauthorized(warn!("Failed to extract authorization: {}", err))))
|
err!(Request(Unauthorized(warn!("Failed to extract authorization: {}", err))))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let is_rendezvous_session = is_rendezvous_session_route(TypeId::of::<R>());
|
|
||||||
if R::RATE_LIMITED && is_rendezvous_session {
|
|
||||||
services.rendezvous.check_session_ratelimit(request_ip)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(authentication) = authentication {
|
if let Some(authentication) = authentication {
|
||||||
check_access_token(services, &authentication, query, TypeId::of::<R>(), &[
|
check_access_token(services, &authentication, query, TypeId::of::<R>(), &[
|
||||||
OAuthClientScope::ApiFullAccess,
|
OAuthClientScope::ApiFullAccess,
|
||||||
@@ -294,7 +285,7 @@ impl CheckAuth for NoAccessToken {
|
|||||||
.await
|
.await
|
||||||
.map(Some)
|
.map(Some)
|
||||||
} else {
|
} else {
|
||||||
if R::RATE_LIMITED && !is_rendezvous_session {
|
if R::RATE_LIMITED {
|
||||||
check_unauthenticated_request_ratelimiting(services, request_ip)?;
|
check_unauthenticated_request_ratelimiting(services, request_ip)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -460,20 +451,6 @@ async fn check_appservice_token(services: &Services, token: &str) -> Result<Regi
|
|||||||
Ok(appservice_info)
|
Ok(appservice_info)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_rendezvous_create_route(route: TypeId) -> bool {
|
|
||||||
route == TypeId::of::<client::rendezvous::discover_rendezvous::msc4388::Request>()
|
|
||||||
|| route
|
|
||||||
== TypeId::of::<client::rendezvous::create_rendezvous_session::msc4388::Request>()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_rendezvous_session_route(route: TypeId) -> bool {
|
|
||||||
route == TypeId::of::<client::rendezvous::get_rendezvous_session::msc4388::Request>()
|
|
||||||
|| route
|
|
||||||
== TypeId::of::<client::rendezvous::update_rendezvous_session::msc4388::Request>()
|
|
||||||
|| route
|
|
||||||
== TypeId::of::<client::rendezvous::delete_rendezvous_session::msc4388::Request>()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn check_unauthenticated_request_ratelimiting(services: &Services, ip: IpAddr) -> Result<()> {
|
fn check_unauthenticated_request_ratelimiting(services: &Services, ip: IpAddr) -> Result<()> {
|
||||||
if services
|
if services
|
||||||
.config
|
.config
|
||||||
|
|||||||
+28
-21
@@ -920,6 +920,19 @@ pub struct Config {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub forget_forced_upon_leave: bool,
|
pub forget_forced_upon_leave: bool,
|
||||||
|
|
||||||
|
/// Set this to true to require authentication when looking up user profiles
|
||||||
|
/// through this server.
|
||||||
|
///
|
||||||
|
/// By default this is false, allowing tools such as matrix.to to access
|
||||||
|
/// profiles of users on this server and on other servers.
|
||||||
|
/// Setting this to true will block those tools, and may block automated
|
||||||
|
/// crawlers from scraping users' profiles, although it will not block
|
||||||
|
/// other homeservers from accessing users' profiles.
|
||||||
|
///
|
||||||
|
/// default: false
|
||||||
|
#[serde(default)]
|
||||||
|
pub require_auth_for_profile_requests: bool,
|
||||||
|
|
||||||
/// Set this to true to require authentication to create a rendezvous
|
/// Set this to true to require authentication to create a rendezvous
|
||||||
/// session. Rendezvous sessions are used for QR code login.
|
/// session. Rendezvous sessions are used for QR code login.
|
||||||
///
|
///
|
||||||
@@ -2988,7 +3001,6 @@ const DEPRECATED_KEYS: &[&str] = &[
|
|||||||
"max_concurrent_requests",
|
"max_concurrent_requests",
|
||||||
"otlp_protocol",
|
"otlp_protocol",
|
||||||
"request_ip_source",
|
"request_ip_source",
|
||||||
"require_auth_for_profile_requests",
|
|
||||||
"roomid_spacehierarchy_cache_capacity",
|
"roomid_spacehierarchy_cache_capacity",
|
||||||
"unredacted_content_max_age_secs",
|
"unredacted_content_max_age_secs",
|
||||||
"well_known_client",
|
"well_known_client",
|
||||||
@@ -3128,41 +3140,41 @@ fn default_database_backups_to_keep() -> i16 { 1 }
|
|||||||
|
|
||||||
fn default_db_write_buffer_capacity_mb() -> f64 { 48.0 + parallelism_scaled_f64(4.0) }
|
fn default_db_write_buffer_capacity_mb() -> f64 { 48.0 + parallelism_scaled_f64(4.0) }
|
||||||
|
|
||||||
fn default_db_cache_capacity_mb() -> f64 { 512.0 + parallelism_scaled_f64(512.0) }
|
fn default_db_cache_capacity_mb() -> f64 { 128.0 + parallelism_scaled_f64(64.0) }
|
||||||
|
|
||||||
fn default_pdu_cache_capacity() -> u32 { parallelism_scaled_u32(50_000).saturating_add(100_000) }
|
fn default_pdu_cache_capacity() -> u32 { parallelism_scaled_u32(10_000).saturating_add(100_000) }
|
||||||
|
|
||||||
fn default_cache_capacity_modifier() -> f64 { 1.0 }
|
fn default_cache_capacity_modifier() -> f64 { 1.0 }
|
||||||
|
|
||||||
fn default_auth_chain_cache_capacity() -> u32 {
|
fn default_auth_chain_cache_capacity() -> u32 {
|
||||||
parallelism_scaled_u32(50_000).saturating_add(100_000)
|
parallelism_scaled_u32(10_000).saturating_add(100_000)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_shorteventid_cache_capacity() -> u32 {
|
fn default_shorteventid_cache_capacity() -> u32 {
|
||||||
parallelism_scaled_u32(100_000).saturating_add(100_000)
|
parallelism_scaled_u32(50_000).saturating_add(100_000)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_eventidshort_cache_capacity() -> u32 {
|
fn default_eventidshort_cache_capacity() -> u32 {
|
||||||
parallelism_scaled_u32(50_000).saturating_add(100_000)
|
parallelism_scaled_u32(25_000).saturating_add(100_000)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_eventid_pdu_cache_capacity() -> u32 {
|
fn default_eventid_pdu_cache_capacity() -> u32 {
|
||||||
parallelism_scaled_u32(50_000).saturating_add(100_000)
|
parallelism_scaled_u32(25_000).saturating_add(100_000)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_shortstatekey_cache_capacity() -> u32 {
|
fn default_shortstatekey_cache_capacity() -> u32 {
|
||||||
parallelism_scaled_u32(100_000).saturating_add(100_000)
|
parallelism_scaled_u32(10_000).saturating_add(100_000)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_statekeyshort_cache_capacity() -> u32 {
|
fn default_statekeyshort_cache_capacity() -> u32 {
|
||||||
parallelism_scaled_u32(50_000).saturating_add(100_000)
|
parallelism_scaled_u32(10_000).saturating_add(100_000)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_servernameevent_data_cache_capacity() -> u32 {
|
fn default_servernameevent_data_cache_capacity() -> u32 {
|
||||||
parallelism_scaled_u32(100_000).saturating_add(100_000)
|
parallelism_scaled_u32(100_000).saturating_add(500_000)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_stateinfo_cache_capacity() -> u32 { parallelism_scaled_u32(500).clamp(100, 12000) }
|
fn default_stateinfo_cache_capacity() -> u32 { parallelism_scaled_u32(100) }
|
||||||
|
|
||||||
fn default_dns_cache_entries() -> u32 { 32768 }
|
fn default_dns_cache_entries() -> u32 { 32768 }
|
||||||
|
|
||||||
@@ -3384,20 +3396,15 @@ fn default_admin_log_capture() -> String {
|
|||||||
|
|
||||||
fn default_admin_room_tag() -> String { "m.server_notice".to_owned() }
|
fn default_admin_room_tag() -> String { "m.server_notice".to_owned() }
|
||||||
|
|
||||||
#[must_use]
|
|
||||||
#[allow(clippy::as_conversions, clippy::cast_precision_loss)]
|
#[allow(clippy::as_conversions, clippy::cast_precision_loss)]
|
||||||
pub fn parallelism_scaled_f64(val: f64) -> f64 { val * (sys::available_parallelism() as f64) }
|
fn parallelism_scaled_f64(val: f64) -> f64 { val * (sys::available_parallelism() as f64) }
|
||||||
|
|
||||||
#[must_use]
|
fn parallelism_scaled_u32(val: u32) -> u32 {
|
||||||
#[allow(clippy::as_conversions, clippy::cast_possible_truncation)]
|
let val = val.try_into().expect("failed to cast u32 to usize");
|
||||||
pub fn parallelism_scaled_u32(val: u32) -> u32 {
|
parallelism_scaled(val).try_into().unwrap_or(u32::MAX)
|
||||||
val.saturating_mul(sys::available_parallelism() as u32)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
fn parallelism_scaled(val: usize) -> usize { val.saturating_mul(sys::available_parallelism()) }
|
||||||
pub fn parallelism_scaled(val: usize) -> usize {
|
|
||||||
val.saturating_mul(sys::available_parallelism())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_db_pool_workers() -> usize {
|
fn default_db_pool_workers() -> usize {
|
||||||
sys::available_parallelism()
|
sys::available_parallelism()
|
||||||
|
|||||||
@@ -171,14 +171,13 @@ impl Error {
|
|||||||
/// Returns the Matrix error code / error kind
|
/// Returns the Matrix error code / error kind
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn kind(&self) -> ErrorKind {
|
pub fn kind(&self) -> ErrorKind {
|
||||||
use ruma::api::error::ErrorKind::{InvalidParam, Unknown, Unrecognized};
|
use ruma::api::error::ErrorKind::{Unknown, Unrecognized};
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
| Self::Federation(_, error) | Self::Ruma(error) =>
|
| Self::Federation(_, error) | Self::Ruma(error) =>
|
||||||
response::ruma_error_kind(error).clone(),
|
response::ruma_error_kind(error).clone(),
|
||||||
| BadRequest(kind, ..) | Self::Request(kind, ..) => kind.clone(),
|
| BadRequest(kind, ..) | Self::Request(kind, ..) => kind.clone(),
|
||||||
| Self::FeatureDisabled(..) => Unrecognized,
|
| Self::FeatureDisabled(..) => Unrecognized,
|
||||||
| Self::Path(_) | Self::Query(_) => InvalidParam,
|
|
||||||
| _ => Unknown,
|
| _ => Unknown,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,7 +194,6 @@ impl Error {
|
|||||||
| Self::FeatureDisabled(..) => response::bad_request_code(&self.kind()),
|
| Self::FeatureDisabled(..) => response::bad_request_code(&self.kind()),
|
||||||
| Self::Reqwest(error) => error.status().unwrap_or(StatusCode::INTERNAL_SERVER_ERROR),
|
| Self::Reqwest(error) => error.status().unwrap_or(StatusCode::INTERNAL_SERVER_ERROR),
|
||||||
| Self::Conflict(_) => StatusCode::CONFLICT,
|
| Self::Conflict(_) => StatusCode::CONFLICT,
|
||||||
| Self::Path(_) | Self::Query(_) => StatusCode::BAD_REQUEST,
|
|
||||||
| Self::Io(error) => response::io_error_code(error.kind()),
|
| Self::Io(error) => response::io_error_code(error.kind()),
|
||||||
| Self::Uiaa(_) => StatusCode::UNAUTHORIZED,
|
| Self::Uiaa(_) => StatusCode::UNAUTHORIZED,
|
||||||
| _ => StatusCode::INTERNAL_SERVER_ERROR,
|
| _ => StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
|
|||||||
@@ -73,9 +73,6 @@ pub(super) fn bad_request_code(kind: &ErrorKind) -> StatusCode {
|
|||||||
// 413
|
// 413
|
||||||
| TooLarge => StatusCode::PAYLOAD_TOO_LARGE,
|
| TooLarge => StatusCode::PAYLOAD_TOO_LARGE,
|
||||||
|
|
||||||
// 409
|
|
||||||
| ConcurrentWrite => StatusCode::CONFLICT,
|
|
||||||
|
|
||||||
// 404
|
// 404
|
||||||
| Unrecognized | NotFound => StatusCode::NOT_FOUND,
|
| Unrecognized | NotFound => StatusCode::NOT_FOUND,
|
||||||
|
|
||||||
|
|||||||
@@ -20,13 +20,10 @@ use std::{
|
|||||||
|
|
||||||
use futures::{Future, FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt, future};
|
use futures::{Future, FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt, future};
|
||||||
use ruma::{
|
use ruma::{
|
||||||
EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId,
|
EventId, Int, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId,
|
||||||
events::{
|
events::{
|
||||||
StateEventType, TimelineEventType,
|
StateEventType, TimelineEventType,
|
||||||
room::{
|
room::member::{MembershipState, RoomMemberEventContent},
|
||||||
member::{MembershipState, RoomMemberEventContent},
|
|
||||||
power_levels::UserPowerLevel,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
int,
|
int,
|
||||||
room_version_rules::{RoomIdFormatVersion, RoomVersionRules, StateResolutionVersion},
|
room_version_rules::{RoomIdFormatVersion, RoomVersionRules, StateResolutionVersion},
|
||||||
@@ -414,7 +411,7 @@ where
|
|||||||
.inspect(|(event_id, pl)| {
|
.inspect(|(event_id, pl)| {
|
||||||
debug!(
|
debug!(
|
||||||
event_id = event_id.as_str(),
|
event_id = event_id.as_str(),
|
||||||
power_level = ?pl,
|
power_level = i64::from(*pl),
|
||||||
"found the power level of an event's sender",
|
"found the power level of an event's sender",
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
@@ -442,29 +439,27 @@ where
|
|||||||
/// `key_fn` is used as to obtain the power level and age of an event for
|
/// `key_fn` is used as to obtain the power level and age of an event for
|
||||||
/// breaking ties (together with the event ID).
|
/// breaking ties (together with the event ID).
|
||||||
#[tracing::instrument(level = "debug", skip_all)]
|
#[tracing::instrument(level = "debug", skip_all)]
|
||||||
pub async fn lexicographical_topological_sort<Id, P, F, Fut, Hasher, S>(
|
pub async fn lexicographical_topological_sort<Id, F, Fut, Hasher, S>(
|
||||||
graph: &HashMap<Id, HashSet<Id, Hasher>, S>,
|
graph: &HashMap<Id, HashSet<Id, Hasher>, S>,
|
||||||
key_fn: &F,
|
key_fn: &F,
|
||||||
) -> Result<Vec<Id>>
|
) -> Result<Vec<Id>>
|
||||||
where
|
where
|
||||||
F: Fn(Id) -> Fut + Sync,
|
F: Fn(Id) -> Fut + Sync,
|
||||||
Fut: Future<Output = Result<(P, MilliSecondsSinceUnixEpoch)>> + Send,
|
Fut: Future<Output = Result<(Int, MilliSecondsSinceUnixEpoch)>> + Send,
|
||||||
Id: Borrow<EventId> + Clone + Eq + Hash + Ord + Send + Sync,
|
Id: Borrow<EventId> + Clone + Eq + Hash + Ord + Send + Sync,
|
||||||
P: Ord + Send,
|
|
||||||
Hasher: BuildHasher + Default + Clone + Send + Sync,
|
Hasher: BuildHasher + Default + Clone + Send + Sync,
|
||||||
S: BuildHasher + Clone + Send + Sync,
|
S: BuildHasher + Clone + Send + Sync,
|
||||||
{
|
{
|
||||||
#[derive(PartialEq, Eq)]
|
#[derive(PartialEq, Eq)]
|
||||||
struct TieBreaker<'a, Id, P> {
|
struct TieBreaker<'a, Id> {
|
||||||
power_level: P,
|
power_level: Int,
|
||||||
origin_server_ts: MilliSecondsSinceUnixEpoch,
|
origin_server_ts: MilliSecondsSinceUnixEpoch,
|
||||||
event_id: &'a Id,
|
event_id: &'a Id,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Id, P> Ord for TieBreaker<'_, Id, P>
|
impl<Id> Ord for TieBreaker<'_, Id>
|
||||||
where
|
where
|
||||||
Id: Ord,
|
Id: Ord,
|
||||||
P: Ord,
|
|
||||||
{
|
{
|
||||||
fn cmp(&self, other: &Self) -> Ordering {
|
fn cmp(&self, other: &Self) -> Ordering {
|
||||||
// NOTE: the power level comparison is "backwards" intentionally.
|
// NOTE: the power level comparison is "backwards" intentionally.
|
||||||
@@ -482,10 +477,9 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Id, P> PartialOrd for TieBreaker<'_, Id, P>
|
impl<Id> PartialOrd for TieBreaker<'_, Id>
|
||||||
where
|
where
|
||||||
Id: Ord,
|
Id: Ord,
|
||||||
P: Ord,
|
|
||||||
{
|
{
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.cmp(other)) }
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.cmp(other)) }
|
||||||
}
|
}
|
||||||
@@ -575,7 +569,7 @@ async fn get_power_level_for_sender<E, F, Fut>(
|
|||||||
event_id: &EventId,
|
event_id: &EventId,
|
||||||
room_version: &RoomVersionRules,
|
room_version: &RoomVersionRules,
|
||||||
fetch_event: &F,
|
fetch_event: &F,
|
||||||
) -> serde_json::Result<UserPowerLevel>
|
) -> serde_json::Result<Int>
|
||||||
where
|
where
|
||||||
F: Fn(OwnedEventId) -> Fut + Sync,
|
F: Fn(OwnedEventId) -> Fut + Sync,
|
||||||
Fut: Future<Output = Option<E>> + Send,
|
Fut: Future<Output = Option<E>> + Send,
|
||||||
@@ -584,7 +578,7 @@ where
|
|||||||
debug!("fetch event ({event_id}) senders power level");
|
debug!("fetch event ({event_id}) senders power level");
|
||||||
|
|
||||||
let Some(event) = fetch_event(event_id.to_owned()).await else {
|
let Some(event) = fetch_event(event_id.to_owned()).await else {
|
||||||
return Ok(UserPowerLevel::Int(int!(0)));
|
return Ok(int!(0));
|
||||||
};
|
};
|
||||||
|
|
||||||
let auth_events: Vec<E> = event
|
let auth_events: Vec<E> = event
|
||||||
@@ -605,7 +599,7 @@ where
|
|||||||
.authorization
|
.authorization
|
||||||
.explicitly_privilege_room_creators
|
.explicitly_privilege_room_creators
|
||||||
{
|
{
|
||||||
return Ok(UserPowerLevel::Infinite);
|
return Ok(Int::MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
let pl = auth_events
|
let pl = auth_events
|
||||||
@@ -615,17 +609,16 @@ where
|
|||||||
let content: PowerLevelsContentFields = match pl {
|
let content: PowerLevelsContentFields = match pl {
|
||||||
// With no m.room.power_levels in scope the create event's defaults
|
// With no m.room.power_levels in scope the create event's defaults
|
||||||
// apply, under which the room creator holds 100 and everyone else 0.
|
// apply, under which the room creator holds 100 and everyone else 0.
|
||||||
| None =>
|
| None => return Ok(if sender_is_creator { int!(100) } else { int!(0) }),
|
||||||
return Ok(UserPowerLevel::Int(if sender_is_creator { int!(100) } else { int!(0) })),
|
|
||||||
| Some(ev) => from_json_str(ev.content().get())?,
|
| Some(ev) => from_json_str(ev.content().get())?,
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(&user_level) = content.get_user_power(event.sender()) {
|
if let Some(&user_level) = content.get_user_power(event.sender()) {
|
||||||
debug!("found {} at power_level {user_level}", event.sender());
|
debug!("found {} at power_level {user_level}", event.sender());
|
||||||
return Ok(UserPowerLevel::Int(user_level));
|
return Ok(user_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(UserPowerLevel::Int(content.users_default))
|
Ok(content.users_default)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
@@ -973,14 +966,11 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reserve depth 0 for events with no mainline power-levels ancestor (spec
|
|
||||||
// position ∞) so they always sort strictly before the oldest mainline
|
|
||||||
// power-levels event (depth 1).
|
|
||||||
let mainline_map: HashMap<_, _> = mainline
|
let mainline_map: HashMap<_, _> = mainline
|
||||||
.iter()
|
.iter()
|
||||||
.rev()
|
.rev()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(idx, eid)| ((*eid).clone(), idx.saturating_add(1)))
|
.map(|(idx, eid)| ((*eid).clone(), idx))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let order_map: HashMap<_, _> = to_sort
|
let order_map: HashMap<_, _> = to_sort
|
||||||
@@ -1145,10 +1135,7 @@ mod tests {
|
|||||||
MilliSecondsSinceUnixEpoch, OwnedEventId, RoomVersionId,
|
MilliSecondsSinceUnixEpoch, OwnedEventId, RoomVersionId,
|
||||||
events::{
|
events::{
|
||||||
StateEventType, TimelineEventType,
|
StateEventType, TimelineEventType,
|
||||||
room::{
|
room::join_rules::{JoinRule, RoomJoinRulesEventContent},
|
||||||
join_rules::{JoinRule, RoomJoinRulesEventContent},
|
|
||||||
power_levels::UserPowerLevel,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
int,
|
int,
|
||||||
room_version_rules::RoomVersionRules,
|
room_version_rules::RoomVersionRules,
|
||||||
@@ -1399,47 +1386,6 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn mainline_sort_orders_no_ancestor_before_oldest_power_level() {
|
|
||||||
let mut events = INITIAL_EVENTS();
|
|
||||||
let mut with_pl = to_pdu_event(
|
|
||||||
"WITH_PL",
|
|
||||||
alice(),
|
|
||||||
TimelineEventType::RoomTopic,
|
|
||||||
Some(""),
|
|
||||||
to_raw_json_value(&json!({ "topic": "with pl" })).unwrap(),
|
|
||||||
&["CREATE", "IPOWER", "IMA"],
|
|
||||||
&["IMA"],
|
|
||||||
);
|
|
||||||
with_pl.origin_server_ts = uint!(50);
|
|
||||||
|
|
||||||
let mut no_pl = to_pdu_event(
|
|
||||||
"NO_PL",
|
|
||||||
alice(),
|
|
||||||
TimelineEventType::RoomTopic,
|
|
||||||
Some(""),
|
|
||||||
to_raw_json_value(&json!({ "topic": "no pl" })).unwrap(),
|
|
||||||
&["CREATE", "IMA"],
|
|
||||||
&["IMA"],
|
|
||||||
);
|
|
||||||
no_pl.origin_server_ts = uint!(100);
|
|
||||||
|
|
||||||
let to_sort = [with_pl.event_id.clone(), no_pl.event_id.clone()];
|
|
||||||
for event in [with_pl, no_pl] {
|
|
||||||
events.insert(event.event_id.clone(), event);
|
|
||||||
}
|
|
||||||
let fetcher = |id: OwnedEventId| {
|
|
||||||
let events = &events;
|
|
||||||
async move { events.get(&id).cloned() }
|
|
||||||
};
|
|
||||||
|
|
||||||
let sorted = super::mainline_sort(&to_sort, Some(event_id("IPOWER")), &fetcher)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(sorted, vec![event_id("NO_PL"), event_id("WITH_PL")]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Events at the start of a room have no `m.room.power_levels` in their
|
/// Events at the start of a room have no `m.room.power_levels` in their
|
||||||
/// auth events, so the sender's power for sort ordering comes from the
|
/// auth events, so the sender's power for sort ordering comes from the
|
||||||
/// create event instead.
|
/// create event instead.
|
||||||
@@ -1480,11 +1426,7 @@ mod tests {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(power_level, int!(100), "the creator should sort with their default power");
|
||||||
power_level,
|
|
||||||
UserPowerLevel::Int(int!(100)),
|
|
||||||
"the creator should sort with their default power"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -1534,83 +1476,14 @@ mod tests {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(alice_power, int!(100), "the content creator should sort with creator power");
|
||||||
alice_power,
|
|
||||||
UserPowerLevel::Int(int!(100)),
|
|
||||||
"the content creator should sort with creator power"
|
|
||||||
);
|
|
||||||
|
|
||||||
let bob_power =
|
let bob_power =
|
||||||
super::get_power_level_for_sender(&event_id("IMB"), &RoomVersionRules::V6, &fetcher)
|
super::get_power_level_for_sender(&event_id("IMB"), &RoomVersionRules::V6, &fetcher)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(bob_power, int!(0), "the create event's sender is not the creator");
|
||||||
bob_power,
|
|
||||||
UserPowerLevel::Int(int!(0)),
|
|
||||||
"the create event's sender is not the creator"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn v12_creator_outranks_max_int_power_level() {
|
|
||||||
use futures::future::ready;
|
|
||||||
use ruma::Int;
|
|
||||||
|
|
||||||
let mut events = INITIAL_EVENTS();
|
|
||||||
let max_pl = to_pdu_event(
|
|
||||||
"MAX_PL",
|
|
||||||
alice(),
|
|
||||||
TimelineEventType::RoomPowerLevels,
|
|
||||||
Some(""),
|
|
||||||
to_raw_json_value(&json!({
|
|
||||||
"users": {
|
|
||||||
bob(): Int::MAX,
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
.unwrap(),
|
|
||||||
&["CREATE", "IMA"],
|
|
||||||
&["IMA"],
|
|
||||||
);
|
|
||||||
let mut bob_event = to_pdu_event(
|
|
||||||
"BOB_EV",
|
|
||||||
bob(),
|
|
||||||
TimelineEventType::RoomJoinRules,
|
|
||||||
Some(""),
|
|
||||||
to_raw_json_value(&json!({ "join_rule": "invite" })).unwrap(),
|
|
||||||
&["CREATE", "MAX_PL", "IMB"],
|
|
||||||
&["MAX_PL"],
|
|
||||||
);
|
|
||||||
bob_event.origin_server_ts = uint!(50);
|
|
||||||
|
|
||||||
let mut alice_event = to_pdu_event(
|
|
||||||
"ALICE_EV",
|
|
||||||
alice(),
|
|
||||||
TimelineEventType::RoomJoinRules,
|
|
||||||
Some(""),
|
|
||||||
to_raw_json_value(&json!({ "join_rule": "public" })).unwrap(),
|
|
||||||
&["CREATE", "MAX_PL", "IMA"],
|
|
||||||
&["MAX_PL"],
|
|
||||||
);
|
|
||||||
alice_event.origin_server_ts = uint!(100);
|
|
||||||
|
|
||||||
let conflicted = hashset![bob_event.event_id.clone(), alice_event.event_id.clone()];
|
|
||||||
let to_sort = vec![bob_event.event_id.clone(), alice_event.event_id.clone()];
|
|
||||||
for event in [max_pl, bob_event, alice_event] {
|
|
||||||
events.insert(event.event_id.clone(), event);
|
|
||||||
}
|
|
||||||
let fetcher = |id: OwnedEventId| ready(events.get(&id).cloned());
|
|
||||||
|
|
||||||
let sorted = super::reverse_topological_power_sort(
|
|
||||||
to_sort,
|
|
||||||
&conflicted,
|
|
||||||
&RoomVersionRules::V12,
|
|
||||||
&fetcher,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(sorted, vec![event_id("ALICE_EV"), event_id("BOB_EV")]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn test_event_sort() {
|
async fn test_event_sort() {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ pub type DigestOut = [u8; 256 / 8];
|
|||||||
/// Sha256 hash (input gather joined by 0xFF bytes)
|
/// Sha256 hash (input gather joined by 0xFF bytes)
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[tracing::instrument(skip(inputs), level = "trace")]
|
#[tracing::instrument(skip(inputs), level = "trace")]
|
||||||
#[allow(clippy::unnecessary_fallible_conversions)]
|
|
||||||
pub fn delimited<'a, T, I>(mut inputs: I) -> DigestOut
|
pub fn delimited<'a, T, I>(mut inputs: I) -> DigestOut
|
||||||
where
|
where
|
||||||
I: Iterator<Item = T> + 'a,
|
I: Iterator<Item = T> + 'a,
|
||||||
@@ -26,7 +25,6 @@ where
|
|||||||
/// Sha256 hash (input gather)
|
/// Sha256 hash (input gather)
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[tracing::instrument(skip(inputs), level = "trace")]
|
#[tracing::instrument(skip(inputs), level = "trace")]
|
||||||
#[allow(clippy::unnecessary_fallible_conversions)]
|
|
||||||
pub fn concat<'a, T, I>(inputs: I) -> DigestOut
|
pub fn concat<'a, T, I>(inputs: I) -> DigestOut
|
||||||
where
|
where
|
||||||
I: Iterator<Item = T> + 'a,
|
I: Iterator<Item = T> + 'a,
|
||||||
@@ -45,7 +43,6 @@ where
|
|||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[tracing::instrument(skip(input), level = "trace")]
|
#[tracing::instrument(skip(input), level = "trace")]
|
||||||
#[allow(clippy::unnecessary_fallible_conversions)]
|
|
||||||
pub fn hash<T>(input: T) -> DigestOut
|
pub fn hash<T>(input: T) -> DigestOut
|
||||||
where
|
where
|
||||||
T: AsRef<[u8]>,
|
T: AsRef<[u8]>,
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ fn descriptor_cf_options(
|
|||||||
let mut opts = set_table_options(opts, &desc, cache)?;
|
let mut opts = set_table_options(opts, &desc, cache)?;
|
||||||
|
|
||||||
opts.set_min_write_buffer_number(1);
|
opts.set_min_write_buffer_number(1);
|
||||||
opts.set_max_write_buffer_number(3);
|
opts.set_max_write_buffer_number(2);
|
||||||
opts.set_write_buffer_size(desc.write_size);
|
opts.set_write_buffer_size(desc.write_size);
|
||||||
|
|
||||||
opts.set_target_file_size_base(desc.file_size);
|
opts.set_target_file_size_base(desc.file_size);
|
||||||
|
|||||||
+8
-28
@@ -76,7 +76,6 @@ full = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
brotli_compression = [
|
brotli_compression = [
|
||||||
"conduwuit-api/brotli_compression",
|
|
||||||
"conduwuit-core/brotli_compression",
|
"conduwuit-core/brotli_compression",
|
||||||
"conduwuit-router/brotli_compression",
|
"conduwuit-router/brotli_compression",
|
||||||
"conduwuit-service/brotli_compression",
|
"conduwuit-service/brotli_compression",
|
||||||
@@ -88,31 +87,30 @@ direct_tls = [
|
|||||||
"conduwuit-router/direct_tls"
|
"conduwuit-router/direct_tls"
|
||||||
]
|
]
|
||||||
element_hacks = [
|
element_hacks = [
|
||||||
"conduwuit-api/element_hacks",
|
|
||||||
"conduwuit-service/element_hacks",
|
"conduwuit-service/element_hacks",
|
||||||
|
"conduwuit-router/element_hacks",
|
||||||
]
|
]
|
||||||
gzip_compression = [
|
gzip_compression = [
|
||||||
"conduwuit-api/gzip_compression",
|
|
||||||
"conduwuit-core/gzip_compression",
|
"conduwuit-core/gzip_compression",
|
||||||
"conduwuit-router/gzip_compression",
|
"conduwuit-router/gzip_compression",
|
||||||
"conduwuit-service/gzip_compression",
|
"conduwuit-service/gzip_compression",
|
||||||
]
|
]
|
||||||
http3 = [
|
http3 = [
|
||||||
"reqwest/http3"
|
"conduwuit-service/http3"
|
||||||
]
|
]
|
||||||
ring = [
|
ring = [
|
||||||
"rustls/ring"
|
"rustls/ring",
|
||||||
]
|
]
|
||||||
|
|
||||||
aws_lc_rs = [
|
aws_lc_rs = [
|
||||||
"rustls/aws_lc_rs",
|
"rustls/aws_lc_rs",
|
||||||
"dep:aws-lc-rs"
|
|
||||||
]
|
]
|
||||||
io_uring = [
|
io_uring = [
|
||||||
"conduwuit-database/io_uring",
|
"conduwuit-service/io_uring",
|
||||||
]
|
]
|
||||||
jemalloc = [
|
jemalloc = [
|
||||||
"conduwuit-core/jemalloc",
|
"conduwuit-core/jemalloc",
|
||||||
"conduwuit-database/jemalloc",
|
"conduwuit-service/jemalloc",
|
||||||
]
|
]
|
||||||
mimalloc = [
|
mimalloc = [
|
||||||
"conduwuit-core/mimalloc",
|
"conduwuit-core/mimalloc",
|
||||||
@@ -144,19 +142,13 @@ perf_measurements = [
|
|||||||
release_max_log_level = [
|
release_max_log_level = [
|
||||||
"tracing/max_level_trace",
|
"tracing/max_level_trace",
|
||||||
"tracing/release_max_level_info",
|
"tracing/release_max_level_info",
|
||||||
"log/max_level_trace",
|
|
||||||
"log/release_max_level_info",
|
|
||||||
"conduwuit-admin/release_max_log_level",
|
|
||||||
"conduwuit-api/release_max_log_level",
|
|
||||||
"conduwuit-core/release_max_log_level",
|
"conduwuit-core/release_max_log_level",
|
||||||
"conduwuit-database/release_max_log_level",
|
|
||||||
"conduwuit-router/release_max_log_level",
|
"conduwuit-router/release_max_log_level",
|
||||||
"conduwuit-service/release_max_log_level",
|
"conduwuit-service/release_max_log_level",
|
||||||
]
|
]
|
||||||
sentry_telemetry = [
|
sentry_telemetry = [
|
||||||
"dep:sentry",
|
"dep:sentry",
|
||||||
"dep:sentry-tracing",
|
"dep:sentry-tracing",
|
||||||
"dep:sentry-tower",
|
|
||||||
"conduwuit-core/sentry_telemetry",
|
"conduwuit-core/sentry_telemetry",
|
||||||
"conduwuit-router/sentry_telemetry",
|
"conduwuit-router/sentry_telemetry",
|
||||||
]
|
]
|
||||||
@@ -179,19 +171,17 @@ url_preview = [
|
|||||||
"conduwuit-service/url_preview",
|
"conduwuit-service/url_preview",
|
||||||
]
|
]
|
||||||
zstd_compression = [
|
zstd_compression = [
|
||||||
"conduwuit-api/zstd_compression",
|
|
||||||
"conduwuit-core/zstd_compression",
|
"conduwuit-core/zstd_compression",
|
||||||
"conduwuit-database/zstd_compression",
|
|
||||||
"conduwuit-router/zstd_compression",
|
"conduwuit-router/zstd_compression",
|
||||||
"conduwuit-service/zstd_compression",
|
"conduwuit-service/zstd_compression",
|
||||||
]
|
]
|
||||||
bindgen-static = [
|
bindgen-static = [
|
||||||
# "bindgen/static"
|
# "bindgen/static"
|
||||||
# "clang-sys/static"
|
# "clang-sys/static"
|
||||||
"conduwuit-database/bindgen-static"
|
"conduwuit-service/bindgen-static"
|
||||||
]
|
]
|
||||||
bindgen-runtime = [
|
bindgen-runtime = [
|
||||||
"conduwuit-database/bindgen-runtime"
|
"conduwuit-service/bindgen-runtime"
|
||||||
]
|
]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
@@ -199,10 +189,7 @@ bindgen-runtime = [
|
|||||||
# clang-sys = {version = "1", default-features = false}
|
# clang-sys = {version = "1", default-features = false}
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
conduwuit-admin.workspace = true
|
|
||||||
conduwuit-api.workspace = true
|
|
||||||
conduwuit-core.workspace = true
|
conduwuit-core.workspace = true
|
||||||
conduwuit-database.workspace = true
|
|
||||||
conduwuit-router.workspace = true
|
conduwuit-router.workspace = true
|
||||||
conduwuit-service.workspace = true
|
conduwuit-service.workspace = true
|
||||||
conduwuit-build-metadata.workspace = true
|
conduwuit-build-metadata.workspace = true
|
||||||
@@ -214,7 +201,6 @@ dtor.workspace = true
|
|||||||
console-subscriber.optional = true
|
console-subscriber.optional = true
|
||||||
console-subscriber.workspace = true
|
console-subscriber.workspace = true
|
||||||
const-str.workspace = true
|
const-str.workspace = true
|
||||||
log.workspace = true
|
|
||||||
opentelemetry.workspace = true
|
opentelemetry.workspace = true
|
||||||
opentelemetry-otlp.optional = true
|
opentelemetry-otlp.optional = true
|
||||||
opentelemetry-otlp.workspace = true
|
opentelemetry-otlp.workspace = true
|
||||||
@@ -222,14 +208,10 @@ opentelemetry-prometheus.workspace = true
|
|||||||
opentelemetry-semantic-conventions.workspace = true
|
opentelemetry-semantic-conventions.workspace = true
|
||||||
opentelemetry_sdk.workspace = true
|
opentelemetry_sdk.workspace = true
|
||||||
prometheus.workspace = true
|
prometheus.workspace = true
|
||||||
sentry-tower.optional = true
|
|
||||||
sentry-tower.workspace = true
|
|
||||||
sentry-tracing.optional = true
|
sentry-tracing.optional = true
|
||||||
sentry-tracing.workspace = true
|
sentry-tracing.workspace = true
|
||||||
sentry.optional = true
|
sentry.optional = true
|
||||||
sentry.workspace = true
|
sentry.workspace = true
|
||||||
tokio-metrics.optional = true
|
|
||||||
tokio-metrics.workspace = true
|
|
||||||
tokio.workspace = true
|
tokio.workspace = true
|
||||||
tracing-flame.optional = true
|
tracing-flame.optional = true
|
||||||
tracing-flame.workspace = true
|
tracing-flame.workspace = true
|
||||||
@@ -239,9 +221,7 @@ tracing-subscriber.workspace = true
|
|||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
tracing-journald = { workspace = true, optional = true }
|
tracing-journald = { workspace = true, optional = true }
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
reqwest = { workspace = true, default-features = false }
|
|
||||||
rustls = { workspace = true, default-features = false }
|
rustls = { workspace = true, default-features = false }
|
||||||
aws-lc-rs = { version = "1.19.0", default-features = false, optional = true }
|
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use axum::{
|
|||||||
extract::State,
|
extract::State,
|
||||||
response::{IntoResponse, Response},
|
response::{IntoResponse, Response},
|
||||||
};
|
};
|
||||||
use conduwuit::{Result, debug_warn, err, error, info, trace};
|
use conduwuit::{Result, debug, debug_error, debug_warn, err, error, trace};
|
||||||
use conduwuit_service::Services;
|
use conduwuit_service::Services;
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
use http::{Method, StatusCode, Uri};
|
use http::{Method, StatusCode, Uri};
|
||||||
@@ -106,11 +106,11 @@ fn handle_result(method: &Method, uri: &Uri, result: Response) -> Result<Respons
|
|||||||
let reason = status.canonical_reason().unwrap_or("Unknown Reason");
|
let reason = status.canonical_reason().unwrap_or("Unknown Reason");
|
||||||
|
|
||||||
if status.is_server_error() {
|
if status.is_server_error() {
|
||||||
info!(%method, %uri, "{code} {reason}");
|
error!(%method, %uri, "{code} {reason}");
|
||||||
} else if status.is_client_error() {
|
} else if status.is_client_error() {
|
||||||
info!(%method, %uri, "{code} {reason}");
|
debug_error!(%method, %uri, "{code} {reason}");
|
||||||
} else if status.is_redirection() {
|
} else if status.is_redirection() {
|
||||||
trace!(%method, %uri, "{code} {reason}");
|
debug!(%method, %uri, "{code} {reason}");
|
||||||
} else {
|
} else {
|
||||||
trace!(%method, %uri, "{code} {reason}");
|
trace!(%method, %uri, "{code} {reason}");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ crate-type = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
bindgen-runtime = [
|
||||||
|
"conduwuit-database/bindgen-runtime"
|
||||||
|
]
|
||||||
|
bindgen-static = [
|
||||||
|
"conduwuit-database/bindgen-static"
|
||||||
|
]
|
||||||
brotli_compression = [
|
brotli_compression = [
|
||||||
"conduwuit-core/brotli_compression",
|
"conduwuit-core/brotli_compression",
|
||||||
"reqwest/brotli",
|
"reqwest/brotli",
|
||||||
@@ -29,6 +35,9 @@ gzip_compression = [
|
|||||||
"conduwuit-core/gzip_compression",
|
"conduwuit-core/gzip_compression",
|
||||||
"reqwest/gzip",
|
"reqwest/gzip",
|
||||||
]
|
]
|
||||||
|
http3 = [
|
||||||
|
"reqwest/http3"
|
||||||
|
]
|
||||||
io_uring = [
|
io_uring = [
|
||||||
"conduwuit-database/io_uring",
|
"conduwuit-database/io_uring",
|
||||||
]
|
]
|
||||||
@@ -123,6 +132,9 @@ lettre.workspace = true
|
|||||||
resolvematrix.workspace = true
|
resolvematrix.workspace = true
|
||||||
serde_urlencoded.workspace = true
|
serde_urlencoded.workspace = true
|
||||||
openidconnect.workspace = true
|
openidconnect.workspace = true
|
||||||
|
# We use this to set TLS backend features on the outdated reqwest bundled by openidconnect,
|
||||||
|
# which is necessary to call `danger_accept_invalid_certs`.
|
||||||
|
reqwest_0_12.workspace = true
|
||||||
rand.workspace = true
|
rand.workspace = true
|
||||||
|
|
||||||
[target.'cfg(all(unix, target_os = "linux"))'.dependencies]
|
[target.'cfg(all(unix, target_os = "linux"))'.dependencies]
|
||||||
|
|||||||
@@ -1,38 +1,25 @@
|
|||||||
use std::{
|
use std::{
|
||||||
net::IpAddr,
|
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::{Duration, Instant},
|
time::{Duration, SystemTime},
|
||||||
};
|
};
|
||||||
|
|
||||||
use conduwuit::{
|
use conduwuit::{Err, Result, SyncMappedMutexGuard, SyncMutex, SyncMutexGuard, at, err, utils};
|
||||||
Err, Error, Result, SyncMappedMutexGuard, SyncMutex, SyncMutexGuard, at, err, utils,
|
|
||||||
};
|
|
||||||
use governor::{
|
|
||||||
DefaultKeyedRateLimiter, Quota, RateLimiter,
|
|
||||||
clock::{Clock, DefaultClock},
|
|
||||||
};
|
|
||||||
use lru_cache::LruCache;
|
use lru_cache::LruCache;
|
||||||
use nonzero_ext::nonzero;
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedTransactionId,
|
OwnedTransactionId,
|
||||||
api::{
|
api::client::rendezvous::{
|
||||||
client::rendezvous::{
|
create_rendezvous_session, delete_rendezvous_session, get_rendezvous_session,
|
||||||
create_rendezvous_session, delete_rendezvous_session, get_rendezvous_session,
|
update_rendezvous_session,
|
||||||
update_rendezvous_session,
|
|
||||||
},
|
|
||||||
error::{ErrorKind, LimitExceededErrorData, RetryAfter},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Service {
|
pub struct Service {
|
||||||
sessions: SyncMutex<LruCache<String, Session>>,
|
sessions: SyncMutex<LruCache<String, Session>>,
|
||||||
create_ratelimiter: DefaultKeyedRateLimiter<IpAddr>,
|
|
||||||
session_ratelimiter: DefaultKeyedRateLimiter<IpAddr>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Session {
|
struct Session {
|
||||||
data: String,
|
data: String,
|
||||||
created_at: Instant,
|
created_at: SystemTime,
|
||||||
last_sequence_token: String,
|
last_sequence_token: String,
|
||||||
transaction_sequences: LruCache<OwnedTransactionId, String>,
|
transaction_sequences: LruCache<OwnedTransactionId, String>,
|
||||||
}
|
}
|
||||||
@@ -40,31 +27,20 @@ struct Session {
|
|||||||
impl Session {
|
impl Session {
|
||||||
const SAVED_TRANSACTION_SEQUENCES: usize = 256;
|
const SAVED_TRANSACTION_SEQUENCES: usize = 256;
|
||||||
|
|
||||||
fn new(data: String, sequence_token: String, now: Instant) -> Self {
|
fn new(data: String, sequence_token: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
data,
|
data,
|
||||||
created_at: now,
|
created_at: SystemTime::now(),
|
||||||
last_sequence_token: sequence_token,
|
last_sequence_token: sequence_token,
|
||||||
transaction_sequences: LruCache::new(Self::SAVED_TRANSACTION_SEQUENCES),
|
transaction_sequences: LruCache::new(Self::SAVED_TRANSACTION_SEQUENCES),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn time_remaining(&self, now: Instant) -> Option<Duration> {
|
|
||||||
let age = now.saturating_duration_since(self.created_at);
|
|
||||||
(age < Service::SESSION_MAX_AGE)
|
|
||||||
.then(|| Service::SESSION_MAX_AGE.saturating_sub(age))
|
|
||||||
.filter(|remaining| !remaining.is_zero())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_expired(&self, now: Instant) -> bool { self.time_remaining(now).is_none() }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl crate::Service for Service {
|
impl crate::Service for Service {
|
||||||
fn build(_: crate::Args<'_>) -> Result<Arc<Self>> {
|
fn build(_: crate::Args<'_>) -> Result<Arc<Self>> {
|
||||||
Ok(Arc::new(Self {
|
Ok(Arc::new(Self {
|
||||||
sessions: SyncMutex::new(LruCache::new(Self::MAX_SESSIONS)),
|
sessions: SyncMutex::new(LruCache::new(Self::MAX_SESSIONS)),
|
||||||
create_ratelimiter: RateLimiter::keyed(Self::CREATE_RATELIMIT),
|
|
||||||
session_ratelimiter: RateLimiter::keyed(Self::SESSION_RATELIMIT),
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,64 +48,25 @@ impl crate::Service for Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Service {
|
impl Service {
|
||||||
const CREATE_RATELIMIT: Quota = Quota::per_minute(nonzero!(30_u32));
|
|
||||||
const MAX_DATA_SIZE_BYTES: usize = 4096;
|
const MAX_DATA_SIZE_BYTES: usize = 4096;
|
||||||
const MAX_SESSIONS: usize = 256;
|
const MAX_SESSIONS: usize = 256;
|
||||||
const SESSION_MAX_AGE: Duration = Duration::from_secs(300);
|
const SESSION_MAX_AGE: Duration = Duration::from_secs(300);
|
||||||
const SESSION_RATELIMIT: Quota = Quota::per_minute(nonzero!(300_u32));
|
|
||||||
const TOKEN_LENGTH: usize = 32;
|
const TOKEN_LENGTH: usize = 32;
|
||||||
|
|
||||||
pub fn check_create_ratelimit(&self, ip: IpAddr) -> Result<()> {
|
|
||||||
Self::check_ratelimiter(&self.create_ratelimiter, ip)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn check_session_ratelimit(&self, ip: IpAddr) -> Result<()> {
|
|
||||||
Self::check_ratelimiter(&self.session_ratelimiter, ip)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn check_ratelimiter(
|
|
||||||
ratelimiter: &DefaultKeyedRateLimiter<IpAddr>,
|
|
||||||
ip: IpAddr,
|
|
||||||
) -> Result<()> {
|
|
||||||
if let Err(not_until) = ratelimiter.check_key(&ip) {
|
|
||||||
let wait_time = not_until.wait_time_from(DefaultClock::default().now());
|
|
||||||
let mut data = LimitExceededErrorData::new();
|
|
||||||
data.retry_after = Some(RetryAfter::Delay(wait_time));
|
|
||||||
return Err(Error::BadRequest(
|
|
||||||
ErrorKind::LimitExceeded(data),
|
|
||||||
"Rate limit exceeded.",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create_token() -> String { utils::random_string(Self::TOKEN_LENGTH) }
|
fn create_token() -> String { utils::random_string(Self::TOKEN_LENGTH) }
|
||||||
|
|
||||||
fn is_valid_opaque_id(id: &str) -> bool {
|
|
||||||
!id.is_empty()
|
|
||||||
&& id.len() <= 255
|
|
||||||
&& id
|
|
||||||
.bytes()
|
|
||||||
.all(|b| b.is_ascii_alphanumeric() || matches!(b, b'-' | b'.' | b'_' | b'~'))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Lock and fetch an unexpired rendezvous session.
|
/// Lock and fetch an unexpired rendezvous session.
|
||||||
fn lock_session(&self, id: &str) -> Result<SyncMappedMutexGuard<'_, Session>> {
|
fn lock_session(&self, id: &str) -> Result<SyncMappedMutexGuard<'_, Session>> {
|
||||||
self.lock_session_at(id, Instant::now())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn lock_session_at(
|
|
||||||
&self,
|
|
||||||
id: &str,
|
|
||||||
now: Instant,
|
|
||||||
) -> Result<SyncMappedMutexGuard<'_, Session>> {
|
|
||||||
// We don't clear out expired sessions manually, the LRU cache will
|
// We don't clear out expired sessions manually, the LRU cache will
|
||||||
// evict them over time
|
// evict them over time
|
||||||
SyncMutexGuard::try_map_or_err(self.sessions.lock(), |sessions| {
|
SyncMutexGuard::try_map_or_err(self.sessions.lock(), |sessions| {
|
||||||
sessions
|
sessions
|
||||||
.get_mut(id)
|
.get_mut(id)
|
||||||
.filter(|session| !session.is_expired(now))
|
.filter(|session| {
|
||||||
|
SystemTime::now()
|
||||||
|
.duration_since(session.created_at)
|
||||||
|
.is_ok_and(|duration| duration < Self::SESSION_MAX_AGE)
|
||||||
|
})
|
||||||
.ok_or_else(|| err!(Request(NotFound("Unknown session"))))
|
.ok_or_else(|| err!(Request(NotFound("Unknown session"))))
|
||||||
})
|
})
|
||||||
.map_err(at!(1))
|
.map_err(at!(1))
|
||||||
@@ -149,7 +86,7 @@ impl Service {
|
|||||||
|
|
||||||
self.sessions
|
self.sessions
|
||||||
.lock()
|
.lock()
|
||||||
.insert(id.clone(), Session::new(data, sequence_token.clone(), Instant::now()));
|
.insert(id.clone(), Session::new(data, sequence_token.clone()));
|
||||||
|
|
||||||
Ok(create_rendezvous_session::msc4388::Response::new(
|
Ok(create_rendezvous_session::msc4388::Response::new(
|
||||||
id,
|
id,
|
||||||
@@ -166,12 +103,6 @@ impl Service {
|
|||||||
sequence_token: String,
|
sequence_token: String,
|
||||||
data: String,
|
data: String,
|
||||||
) -> Result<update_rendezvous_session::msc4388::Response> {
|
) -> Result<update_rendezvous_session::msc4388::Response> {
|
||||||
if !Self::is_valid_opaque_id(transaction.as_str()) {
|
|
||||||
return Err!(Request(InvalidParam(
|
|
||||||
"Transaction ID does not comply with the opaque identifier grammar"
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut session = self.lock_session(id)?;
|
let mut session = self.lock_session(id)?;
|
||||||
|
|
||||||
// If the provided transaction ID was used already, we have to return
|
// If the provided transaction ID was used already, we have to return
|
||||||
@@ -206,12 +137,13 @@ impl Service {
|
|||||||
|
|
||||||
/// Look up a rendezvous session by ID.
|
/// Look up a rendezvous session by ID.
|
||||||
pub fn get_session(&self, id: &str) -> Result<get_rendezvous_session::msc4388::Response> {
|
pub fn get_session(&self, id: &str) -> Result<get_rendezvous_session::msc4388::Response> {
|
||||||
let now = Instant::now();
|
let session = self.lock_session(id)?;
|
||||||
let session = self.lock_session_at(id, now)?;
|
|
||||||
|
|
||||||
let session_time_remaining = session
|
let session_age = SystemTime::now()
|
||||||
.time_remaining(now)
|
.duration_since(session.created_at)
|
||||||
.unwrap_or_else(|| Duration::from_millis(1));
|
.unwrap_or(Duration::MAX);
|
||||||
|
|
||||||
|
let session_time_remaining = Self::SESSION_MAX_AGE.saturating_sub(session_age);
|
||||||
|
|
||||||
Ok(get_rendezvous_session::msc4388::Response::new(
|
Ok(get_rendezvous_session::msc4388::Response::new(
|
||||||
session.last_sequence_token.clone(),
|
session.last_sequence_token.clone(),
|
||||||
@@ -226,12 +158,8 @@ impl Service {
|
|||||||
id: &str,
|
id: &str,
|
||||||
) -> Result<delete_rendezvous_session::msc4388::Response> {
|
) -> Result<delete_rendezvous_session::msc4388::Response> {
|
||||||
let mut sessions = self.sessions.lock();
|
let mut sessions = self.sessions.lock();
|
||||||
let now = Instant::now();
|
|
||||||
|
|
||||||
if sessions
|
if sessions.remove(id).is_some() {
|
||||||
.remove(id)
|
|
||||||
.is_some_and(|session| !session.is_expired(now))
|
|
||||||
{
|
|
||||||
Ok(delete_rendezvous_session::msc4388::Response::new())
|
Ok(delete_rendezvous_session::msc4388::Response::new())
|
||||||
} else {
|
} else {
|
||||||
Err!(Request(NotFound("Unknown session")))
|
Err!(Request(NotFound("Unknown session")))
|
||||||
|
|||||||
@@ -522,6 +522,13 @@ impl Service {
|
|||||||
let device_changes =
|
let device_changes =
|
||||||
self.select_edus_device_changes(server_name, batch, &max_edu_count, &events_len);
|
self.select_edus_device_changes(server_name, batch, &max_edu_count, &events_len);
|
||||||
|
|
||||||
|
let receipts: OptionFuture<_> = self
|
||||||
|
.server
|
||||||
|
.config
|
||||||
|
.allow_outgoing_read_receipts
|
||||||
|
.then(|| self.select_edus_receipts(server_name, batch, &max_edu_count))
|
||||||
|
.into();
|
||||||
|
|
||||||
let presence: OptionFuture<_> = self
|
let presence: OptionFuture<_> = self
|
||||||
.server
|
.server
|
||||||
.config
|
.config
|
||||||
@@ -529,20 +536,11 @@ impl Service {
|
|||||||
.then(|| self.select_edus_presence(server_name, batch, &max_edu_count))
|
.then(|| self.select_edus_presence(server_name, batch, &max_edu_count))
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
let (device_changes, presence) = join!(device_changes, presence);
|
let (device_changes, receipts, presence) = join!(device_changes, receipts, presence);
|
||||||
|
|
||||||
let mut events = device_changes;
|
let mut events = device_changes;
|
||||||
events.extend(presence.into_iter().flatten());
|
events.extend(presence.into_iter().flatten());
|
||||||
|
events.extend(receipts.into_iter().flatten());
|
||||||
// leave a slot for the queued event, but always allow one receipt EDU
|
|
||||||
let edu_limit = (EDU_LIMIT - 1).saturating_sub(events.len()).max(1);
|
|
||||||
if self.server.config.allow_outgoing_read_receipts {
|
|
||||||
// must be selected last, as it may lower max_edu_count
|
|
||||||
events.extend(
|
|
||||||
self.select_edus_receipts(server_name, batch, &max_edu_count, edu_limit)
|
|
||||||
.await,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(nex): some EDUs like typing need flattening
|
// TODO(nex): some EDUs like typing need flattening
|
||||||
|
|
||||||
@@ -618,11 +616,9 @@ impl Service {
|
|||||||
server_name: &ServerName,
|
server_name: &ServerName,
|
||||||
since: (u64, u64),
|
since: (u64, u64),
|
||||||
max_edu_count: &AtomicU64,
|
max_edu_count: &AtomicU64,
|
||||||
edu_limit: usize,
|
) -> Option<EduBuf> {
|
||||||
) -> EduVec {
|
|
||||||
let num = AtomicUsize::new(0);
|
let num = AtomicUsize::new(0);
|
||||||
let deferred = AtomicU64::new(u64::MAX);
|
let receipts: BTreeMap<OwnedRoomId, ReceiptMap> = self
|
||||||
let rooms: Vec<_> = self
|
|
||||||
.services
|
.services
|
||||||
.state_cache
|
.state_cache
|
||||||
.server_rooms(server_name)
|
.server_rooms(server_name)
|
||||||
@@ -631,54 +627,33 @@ impl Service {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let maps = self
|
let receipt_map = self
|
||||||
.select_edus_receipts_room(
|
.select_edus_receipts_room(&room_id, since, max_edu_count, &num)
|
||||||
&room_id,
|
|
||||||
since,
|
|
||||||
max_edu_count,
|
|
||||||
&num,
|
|
||||||
edu_limit,
|
|
||||||
&deferred,
|
|
||||||
)
|
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
(!maps.is_empty()).then_some((room_id, maps))
|
(!receipt_map.read.is_empty()).then_some((room_id, receipt_map))
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
// the next transaction starts at the first receipt that did not fit
|
if receipts.is_empty() {
|
||||||
max_edu_count
|
return None;
|
||||||
.fetch_min(deferred.load(Ordering::Relaxed).saturating_sub(1), Ordering::Relaxed);
|
|
||||||
|
|
||||||
let mut contents = Vec::<BTreeMap<OwnedRoomId, ReceiptMap>>::new();
|
|
||||||
for (room_id, maps) in rooms {
|
|
||||||
for (index, read) in maps.into_iter().enumerate() {
|
|
||||||
if index == contents.len() {
|
|
||||||
contents.push(BTreeMap::new());
|
|
||||||
}
|
|
||||||
contents[index].insert(room_id.clone(), ReceiptMap::new(read));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contents
|
let receipt_content = Edu::Receipt(ReceiptContent::new(receipts));
|
||||||
.into_iter()
|
|
||||||
.map(|content| {
|
|
||||||
let edu = Edu::Receipt(ReceiptContent::new(content));
|
|
||||||
|
|
||||||
let mut buf = EduBuf::new();
|
let mut buf = EduBuf::new();
|
||||||
serde_json::to_writer(&mut buf, &edu)
|
serde_json::to_writer(&mut buf, &receipt_content)
|
||||||
.expect("Failed to serialize Receipt EDU to JSON vec");
|
.expect("Failed to serialize Receipt EDU to JSON vec");
|
||||||
buf
|
|
||||||
})
|
Some(buf)
|
||||||
.collect()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Look for read receipts in this room
|
/// Look for read receipts in this room
|
||||||
#[tracing::instrument(
|
#[tracing::instrument(
|
||||||
name = "receipts",
|
name = "receipts",
|
||||||
level = "trace",
|
level = "trace",
|
||||||
skip(self, since, max_edu_count, num, deferred)
|
skip(self, since, max_edu_count, num)
|
||||||
)]
|
)]
|
||||||
async fn select_edus_receipts_room(
|
async fn select_edus_receipts_room(
|
||||||
&self,
|
&self,
|
||||||
@@ -686,16 +661,14 @@ impl Service {
|
|||||||
since: (u64, u64),
|
since: (u64, u64),
|
||||||
max_edu_count: &AtomicU64,
|
max_edu_count: &AtomicU64,
|
||||||
num: &AtomicUsize,
|
num: &AtomicUsize,
|
||||||
edu_limit: usize,
|
) -> ReceiptMap {
|
||||||
deferred: &AtomicU64,
|
|
||||||
) -> Vec<BTreeMap<OwnedUserId, ReceiptData>> {
|
|
||||||
let receipts = self
|
let receipts = self
|
||||||
.services
|
.services
|
||||||
.read_receipt
|
.read_receipt
|
||||||
.readreceipts_since(room_id, Some(since.0));
|
.readreceipts_since(room_id, Some(since.0));
|
||||||
|
|
||||||
pin_mut!(receipts);
|
pin_mut!(receipts);
|
||||||
let mut maps = Vec::new();
|
let mut read = BTreeMap::<OwnedUserId, ReceiptData>::new();
|
||||||
while let Some((user_id, count, read_receipt)) = receipts.next().await {
|
while let Some((user_id, count, read_receipt)) = receipts.next().await {
|
||||||
if count > since.1 {
|
if count > since.1 {
|
||||||
break;
|
break;
|
||||||
@@ -731,20 +704,14 @@ impl Service {
|
|||||||
|
|
||||||
let receipt_data = ReceiptData::new(receipt, vec![event_id]);
|
let receipt_data = ReceiptData::new(receipt, vec![event_id]);
|
||||||
|
|
||||||
let Some(index) = add_receipt(&mut maps, user_id, receipt_data, edu_limit) else {
|
if read.insert(user_id, receipt_data).is_none() {
|
||||||
deferred.fetch_min(count, Ordering::Relaxed);
|
if num.fetch_add(1, Ordering::Relaxed).saturating_add(1) >= SELECT_RECEIPT_LIMIT {
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
|
|
||||||
// only a user's first receipt counts towards the limit
|
|
||||||
if index == 0
|
|
||||||
&& num.fetch_add(1, Ordering::Relaxed).saturating_add(1) >= SELECT_RECEIPT_LIMIT
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
maps
|
ReceiptMap::new(read)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Look for presence
|
/// Look for presence
|
||||||
@@ -1143,27 +1110,3 @@ impl Service {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds the receipt to the first map without one from the user and returns
|
|
||||||
/// that map's index, or `None` if all `limit` maps have one.
|
|
||||||
fn add_receipt(
|
|
||||||
maps: &mut Vec<BTreeMap<OwnedUserId, ReceiptData>>,
|
|
||||||
user_id: OwnedUserId,
|
|
||||||
receipt: ReceiptData,
|
|
||||||
limit: usize,
|
|
||||||
) -> Option<usize> {
|
|
||||||
let index = maps
|
|
||||||
.iter()
|
|
||||||
.position(|map| !map.contains_key(&user_id))
|
|
||||||
.unwrap_or(maps.len());
|
|
||||||
if index >= limit {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
if index == maps.len() {
|
|
||||||
maps.push(BTreeMap::new());
|
|
||||||
}
|
|
||||||
maps[index].insert(user_id, receipt);
|
|
||||||
|
|
||||||
Some(index)
|
|
||||||
}
|
|
||||||
@@ -1,19 +1,14 @@
|
|||||||
use std::{collections::BTreeMap, iter::once};
|
use std::iter::once;
|
||||||
|
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Error,
|
Error,
|
||||||
matrix::{PartialPdu, pdu::sticky},
|
matrix::{PartialPdu, pdu::sticky},
|
||||||
};
|
};
|
||||||
use futures::{StreamExt, stream::FuturesUnordered};
|
use futures::{StreamExt, stream::FuturesUnordered};
|
||||||
use ruma::{
|
use ruma::{RoomId, UserId, events::sticky::StickyDurationMs, server_name};
|
||||||
RoomId, UserId,
|
|
||||||
api::federation::transactions::edu::ReceiptData,
|
|
||||||
events::{receipt::Receipt, sticky::StickyDurationMs},
|
|
||||||
server_name, user_id,
|
|
||||||
};
|
|
||||||
use serde_json::{json, value::to_raw_value};
|
use serde_json::{json, value::to_raw_value};
|
||||||
|
|
||||||
use super::{CurTransactionStatus, TransactionStatus, add_receipt};
|
use super::{CurTransactionStatus, TransactionStatus};
|
||||||
use crate::{
|
use crate::{
|
||||||
sending::{Destination, EduBuf, SendingEvent},
|
sending::{Destination, EduBuf, SendingEvent},
|
||||||
test_utils::{test_services, test_services_with},
|
test_utils::{test_services, test_services_with},
|
||||||
@@ -201,17 +196,3 @@ async fn restarted_worker_keeps_sticky_events_when_startup_netburst_is_disabled(
|
|||||||
assert_eq!(active_after_startup, 0);
|
assert_eq!(active_after_startup, 0);
|
||||||
assert_eq!(sending_after_startup, 0);
|
assert_eq!(sending_after_startup, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn add_receipt_separates_receipts_of_one_user() {
|
|
||||||
let alice = user_id!("@alice:example.org");
|
|
||||||
let bob = user_id!("@bob:example.org");
|
|
||||||
let receipt = || ReceiptData::new(Receipt::default(), vec![]);
|
|
||||||
let mut maps = Vec::new();
|
|
||||||
|
|
||||||
assert_eq!(add_receipt(&mut maps, alice.to_owned(), receipt(), 2), Some(0));
|
|
||||||
assert_eq!(add_receipt(&mut maps, alice.to_owned(), receipt(), 2), Some(1));
|
|
||||||
assert_eq!(add_receipt(&mut maps, bob.to_owned(), receipt(), 2), Some(0));
|
|
||||||
assert_eq!(add_receipt(&mut maps, alice.to_owned(), receipt(), 2), None);
|
|
||||||
assert_eq!(maps.iter().map(BTreeMap::len).collect::<Vec<_>>(), [2, 1]);
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user