Merge branch 'jaeger' into 'master'
feat: opentelemetry/jaeger support See merge request famedly/conduit!28next
commit
1a198e7336
|
@ -30,6 +30,15 @@ dependencies = [
|
|||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
||||
dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
version = "0.3.6"
|
||||
|
@ -212,7 +221,9 @@ dependencies = [
|
|||
"js_int",
|
||||
"jsonwebtoken",
|
||||
"log",
|
||||
"rand",
|
||||
"opentelemetry",
|
||||
"opentelemetry-jaeger",
|
||||
"rand 0.7.3",
|
||||
"regex",
|
||||
"reqwest",
|
||||
"ring",
|
||||
|
@ -226,6 +237,9 @@ dependencies = [
|
|||
"state-res",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-opentelemetry",
|
||||
"tracing-subscriber",
|
||||
"trust-dns-resolver",
|
||||
]
|
||||
|
||||
|
@ -595,6 +609,17 @@ dependencies = [
|
|||
"wasi 0.9.0+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
"wasi 0.10.0+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gif"
|
||||
version = "0.11.1"
|
||||
|
@ -795,6 +820,12 @@ dependencies = [
|
|||
"cfg-if 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "integer-encoding"
|
||||
version = "1.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48dc51180a9b377fd75814d0cc02199c20f8e99433d6762f650d39cdbbd3b56f"
|
||||
|
||||
[[package]]
|
||||
name = "iovec"
|
||||
version = "0.1.4"
|
||||
|
@ -945,6 +976,15 @@ version = "0.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4"
|
||||
|
||||
[[package]]
|
||||
name = "matchers"
|
||||
version = "0.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1"
|
||||
dependencies = [
|
||||
"regex-automata",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matches"
|
||||
version = "0.1.8"
|
||||
|
@ -1189,6 +1229,44 @@ dependencies = [
|
|||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "opentelemetry"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "514d24875c140ed269eecc2d1b56d7b71b573716922a763c317fb1b1b4b58f15"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"futures",
|
||||
"js-sys",
|
||||
"lazy_static",
|
||||
"percent-encoding",
|
||||
"pin-project 1.0.2",
|
||||
"rand 0.8.3",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "opentelemetry-jaeger"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5677b3a361784aff6e2b1b30dbdb5f85f4ec57ff2ced41d9a481ad70a9d0b57"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"lazy_static",
|
||||
"opentelemetry",
|
||||
"thiserror",
|
||||
"thrift",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ordered-float"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3305af35278dd29f46fcdd139e0b1fbfae2153f0e5928b39b035542dd31e37b7"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.11.1"
|
||||
|
@ -1406,11 +1484,23 @@ version = "0.7.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"getrandom 0.1.15",
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
"rand_chacha 0.2.2",
|
||||
"rand_core 0.5.1",
|
||||
"rand_hc 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha 0.3.0",
|
||||
"rand_core 0.6.2",
|
||||
"rand_hc 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1420,7 +1510,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
"rand_core 0.5.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core 0.6.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1429,7 +1529,16 @@ version = "0.5.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"getrandom 0.1.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
|
||||
dependencies = [
|
||||
"getrandom 0.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1438,7 +1547,16 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
"rand_core 0.5.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||
dependencies = [
|
||||
"rand_core 0.6.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1453,7 +1571,7 @@ version = "0.3.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"getrandom 0.1.15",
|
||||
"redox_syscall",
|
||||
"rust-argon2",
|
||||
]
|
||||
|
@ -1490,6 +1608,16 @@ dependencies = [
|
|||
"thread_local",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.21"
|
||||
|
@ -1582,7 +1710,7 @@ dependencies = [
|
|||
"memchr",
|
||||
"num_cpus",
|
||||
"parking_lot",
|
||||
"rand",
|
||||
"rand 0.7.3",
|
||||
"ref-cast",
|
||||
"rocket_codegen",
|
||||
"rocket_http",
|
||||
|
@ -1769,7 +1897,7 @@ version = "0.17.4"
|
|||
source = "git+https://github.com/ruma/ruma?rev=ee814aa84934530d76f5e4b275d739805b49bdef#ee814aa84934530d76f5e4b275d739805b49bdef"
|
||||
dependencies = [
|
||||
"paste",
|
||||
"rand",
|
||||
"rand 0.7.3",
|
||||
"ruma-identifiers-macros",
|
||||
"ruma-identifiers-validation",
|
||||
"ruma-serde",
|
||||
|
@ -2010,6 +2138,15 @@ version = "0.6.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
|
||||
|
||||
[[package]]
|
||||
name = "sharded-slab"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79c719719ee05df97490f80a45acfc99e5a30ce98a1e4fb67aee422745ae14e3"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.2.2"
|
||||
|
@ -2194,7 +2331,7 @@ checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
|
|||
dependencies = [
|
||||
"cfg-if 0.1.10",
|
||||
"libc",
|
||||
"rand",
|
||||
"rand 0.7.3",
|
||||
"redox_syscall",
|
||||
"remove_dir_all",
|
||||
"winapi 0.3.9",
|
||||
|
@ -2229,6 +2366,28 @@ dependencies = [
|
|||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "threadpool"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
|
||||
dependencies = [
|
||||
"num_cpus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thrift"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c6d965454947cc7266d22716ebfd07b18d84ebaf35eec558586bbb2a8cb6b5b"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"integer-encoding",
|
||||
"log",
|
||||
"ordered-float",
|
||||
"threadpool",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.1.44"
|
||||
|
@ -2380,9 +2539,9 @@ checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860"
|
|||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.22"
|
||||
version = "0.1.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3"
|
||||
checksum = "01ebdc2bb4498ab1ab5f5b73c5803825e60199229ccba0698170e3be0e7f959f"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"log",
|
||||
|
@ -2393,9 +2552,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tracing-attributes"
|
||||
version = "0.1.11"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada"
|
||||
checksum = "a8a9bd1db7706f2373a190b0d067146caa39350c486f3d455b0e33b431f94c07"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -2421,6 +2580,62 @@ dependencies = [
|
|||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-log"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"log",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-opentelemetry"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cccdf13c28f1654fe806838f28c5b9cb23ca4c0eae71450daa489f50e523ceb1"
|
||||
dependencies = [
|
||||
"opentelemetry",
|
||||
"tracing",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-serde"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"tracing-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tracing-subscriber"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ab8966ac3ca27126141f7999361cc97dd6fb4b71da04c02044fa9045d98bb96"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"chrono",
|
||||
"lazy_static",
|
||||
"matchers",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sharded-slab",
|
||||
"smallvec",
|
||||
"thread_local",
|
||||
"tracing",
|
||||
"tracing-core",
|
||||
"tracing-log",
|
||||
"tracing-serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "trust-dns-proto"
|
||||
version = "0.19.6"
|
||||
|
@ -2434,7 +2649,7 @@ dependencies = [
|
|||
"idna",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"rand",
|
||||
"rand 0.7.3",
|
||||
"smallvec",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
|
|
|
@ -65,6 +65,12 @@ trust-dns-resolver = "0.19.6"
|
|||
regex = "1.4.2"
|
||||
# jwt jsonwebtokens
|
||||
jsonwebtoken = "7.2.0"
|
||||
# Performance measurements
|
||||
tracing = "0.1.25"
|
||||
opentelemetry = "0.12.0"
|
||||
tracing-subscriber = "0.2.16"
|
||||
tracing-opentelemetry = "0.11.0"
|
||||
opentelemetry-jaeger = "0.11.0"
|
||||
|
||||
[features]
|
||||
default = ["conduit_bin"]
|
||||
|
|
|
@ -28,8 +28,12 @@ max_request_size = 20_000_000 # in bytes
|
|||
# Disable encryption, so no new encrypted rooms can be created
|
||||
# Note: existing rooms will continue to work
|
||||
#allow_encryption = true
|
||||
|
||||
#allow_federation = false
|
||||
|
||||
# Enable jaeger to support monitoring and troubleshooting through jaeger
|
||||
#allow_jaeger = false
|
||||
|
||||
#cache_capacity = 1073741824 # in bytes, 1024 * 1024 * 1024
|
||||
#max_concurrent_requests = 4 # How many requests Conduit sends to other servers at the same time
|
||||
#workers = 4 # default: cpu core count * 2
|
||||
|
|
|
@ -40,6 +40,7 @@ const GUEST_NAME_LENGTH: usize = 10;
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/register/available", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_register_available_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_username_availability::Request<'_>>,
|
||||
|
@ -82,6 +83,7 @@ pub async fn get_register_available_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/register", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn register_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<register::Request<'_>>,
|
||||
|
@ -546,6 +548,7 @@ pub async fn register_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/account/password", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn change_password_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<change_password::Request<'_>>,
|
||||
|
@ -610,6 +613,7 @@ pub async fn change_password_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/account/whoami", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(body))]
|
||||
pub async fn whoami_route(body: Ruma<whoami::Request>) -> ConduitResult<whoami::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
Ok(whoami::Response {
|
||||
|
@ -630,6 +634,7 @@ pub async fn whoami_route(body: Ruma<whoami::Request>) -> ConduitResult<whoami::
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/account/deactivate", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn deactivate_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<deactivate::Request<'_>>,
|
||||
|
|
|
@ -19,6 +19,7 @@ use rocket::{delete, get, put};
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/r0/directory/room/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn create_alias_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<create_alias::Request<'_>>,
|
||||
|
@ -39,6 +40,7 @@ pub async fn create_alias_route(
|
|||
feature = "conduit_bin",
|
||||
delete("/_matrix/client/r0/directory/room/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_alias_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<delete_alias::Request<'_>>,
|
||||
|
@ -54,6 +56,7 @@ pub async fn delete_alias_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/directory/room/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_alias_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_alias::Request<'_>>,
|
||||
|
|
|
@ -17,6 +17,7 @@ use rocket::{delete, get, post, put};
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/unstable/room_keys/version", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn create_backup_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<create_backup::Request>,
|
||||
|
@ -35,6 +36,7 @@ pub async fn create_backup_route(
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/unstable/room_keys/version/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn update_backup_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<update_backup::Request<'_>>,
|
||||
|
@ -52,6 +54,7 @@ pub async fn update_backup_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/unstable/room_keys/version", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_latest_backup_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_latest_backup::Request>,
|
||||
|
@ -79,6 +82,7 @@ pub async fn get_latest_backup_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/unstable/room_keys/version/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_backup_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_backup::Request<'_>>,
|
||||
|
@ -105,6 +109,7 @@ pub async fn get_backup_route(
|
|||
feature = "conduit_bin",
|
||||
delete("/_matrix/client/unstable/room_keys/version/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_backup_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<delete_backup::Request<'_>>,
|
||||
|
@ -123,6 +128,7 @@ pub async fn delete_backup_route(
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/unstable/room_keys/keys", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn add_backup_keys_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<add_backup_keys::Request<'_>>,
|
||||
|
@ -156,6 +162,7 @@ pub async fn add_backup_keys_route(
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/unstable/room_keys/keys/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn add_backup_key_sessions_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<add_backup_key_sessions::Request<'_>>,
|
||||
|
@ -187,6 +194,7 @@ pub async fn add_backup_key_sessions_route(
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/unstable/room_keys/keys/<_>/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn add_backup_key_session_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<add_backup_key_session::Request<'_>>,
|
||||
|
@ -215,6 +223,7 @@ pub async fn add_backup_key_session_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/unstable/room_keys/keys", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_backup_keys_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_backup_keys::Request<'_>>,
|
||||
|
@ -230,6 +239,7 @@ pub async fn get_backup_keys_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/unstable/room_keys/keys/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_backup_key_sessions_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_backup_key_sessions::Request<'_>>,
|
||||
|
@ -247,6 +257,7 @@ pub async fn get_backup_key_sessions_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/unstable/room_keys/keys/<_>/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_backup_key_session_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_backup_key_session::Request<'_>>,
|
||||
|
@ -270,6 +281,7 @@ pub async fn get_backup_key_session_route(
|
|||
feature = "conduit_bin",
|
||||
delete("/_matrix/client/unstable/room_keys/keys", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_backup_keys_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<delete_backup_keys::Request<'_>>,
|
||||
|
@ -292,6 +304,7 @@ pub async fn delete_backup_keys_route(
|
|||
feature = "conduit_bin",
|
||||
delete("/_matrix/client/unstable/room_keys/keys/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_backup_key_sessions_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<delete_backup_key_sessions::Request<'_>>,
|
||||
|
@ -314,6 +327,7 @@ pub async fn delete_backup_key_sessions_route(
|
|||
feature = "conduit_bin",
|
||||
delete("/_matrix/client/unstable/room_keys/keys/<_>/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_backup_key_session_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<delete_backup_key_session::Request<'_>>,
|
||||
|
|
|
@ -9,6 +9,7 @@ use rocket::get;
|
|||
///
|
||||
/// Get information on this server's supported feature set and other relevent capabilities.
|
||||
#[cfg_attr(feature = "conduit_bin", get("/_matrix/client/r0/capabilities"))]
|
||||
#[tracing::instrument]
|
||||
pub async fn get_capabilities_route() -> ConduitResult<get_capabilities::Response> {
|
||||
let mut available = BTreeMap::new();
|
||||
available.insert(
|
||||
|
|
|
@ -16,6 +16,7 @@ use rocket::{get, put};
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/r0/user/<_>/account_data/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_global_account_data_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<set_global_account_data::Request<'_>>,
|
||||
|
@ -49,6 +50,7 @@ pub async fn set_global_account_data_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/user/<_>/account_data/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_global_account_data_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_global_account_data::Request<'_>>,
|
||||
|
|
|
@ -10,6 +10,7 @@ use rocket::get;
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/rooms/<_>/context/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_context_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_context::Request<'_>>,
|
||||
|
|
|
@ -16,6 +16,7 @@ use rocket::{delete, get, post, put};
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/devices", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_devices_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_devices::Request>,
|
||||
|
@ -35,6 +36,7 @@ pub async fn get_devices_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/devices/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_device_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_device::Request<'_>>,
|
||||
|
@ -53,6 +55,7 @@ pub async fn get_device_route(
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/r0/devices/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn update_device_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<update_device::Request<'_>>,
|
||||
|
@ -78,6 +81,7 @@ pub async fn update_device_route(
|
|||
feature = "conduit_bin",
|
||||
delete("/_matrix/client/r0/devices/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_device_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<delete_device::Request<'_>>,
|
||||
|
@ -126,6 +130,7 @@ pub async fn delete_device_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/delete_devices", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_devices_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<delete_devices::Request<'_>>,
|
||||
|
|
|
@ -31,6 +31,7 @@ use rocket::{get, post, put};
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/publicRooms", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_public_rooms_filtered_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_public_rooms_filtered::Request<'_>>,
|
||||
|
@ -50,6 +51,7 @@ pub async fn get_public_rooms_filtered_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/publicRooms", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_public_rooms_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_public_rooms::Request<'_>>,
|
||||
|
@ -78,6 +80,7 @@ pub async fn get_public_rooms_route(
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/r0/directory/list/room/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_room_visibility_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<set_room_visibility::Request<'_>>,
|
||||
|
@ -107,6 +110,7 @@ pub async fn set_room_visibility_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/directory/list/room/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_room_visibility_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_room_visibility::Request<'_>>,
|
||||
|
|
|
@ -5,6 +5,7 @@ use ruma::api::client::r0::filter::{self, create_filter, get_filter};
|
|||
use rocket::{get, post};
|
||||
|
||||
#[cfg_attr(feature = "conduit_bin", get("/_matrix/client/r0/user/<_>/filter/<_>"))]
|
||||
#[tracing::instrument]
|
||||
pub async fn get_filter_route() -> ConduitResult<get_filter::Response> {
|
||||
// TODO
|
||||
Ok(get_filter::Response::new(filter::IncomingFilterDefinition {
|
||||
|
@ -18,6 +19,7 @@ pub async fn get_filter_route() -> ConduitResult<get_filter::Response> {
|
|||
}
|
||||
|
||||
#[cfg_attr(feature = "conduit_bin", post("/_matrix/client/r0/user/<_>/filter"))]
|
||||
#[tracing::instrument]
|
||||
pub async fn create_filter_route() -> ConduitResult<create_filter::Response> {
|
||||
// TODO
|
||||
Ok(create_filter::Response::new(utils::random_string(10)).into())
|
||||
|
|
|
@ -22,6 +22,7 @@ use rocket::{get, post};
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/keys/upload", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn upload_keys_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<upload_keys::Request>,
|
||||
|
@ -70,6 +71,7 @@ pub async fn upload_keys_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/keys/query", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_keys_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_keys::Request<'_>>,
|
||||
|
@ -150,6 +152,7 @@ pub async fn get_keys_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/keys/claim", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn claim_keys_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<claim_keys::Request>,
|
||||
|
@ -183,6 +186,7 @@ pub async fn claim_keys_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/unstable/keys/device_signing/upload", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn upload_signing_keys_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<upload_signing_keys::Request<'_>>,
|
||||
|
@ -240,6 +244,7 @@ pub async fn upload_signing_keys_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/unstable/keys/signatures/upload", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn upload_signatures_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<upload_signatures::Request>,
|
||||
|
@ -300,6 +305,7 @@ pub async fn upload_signatures_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/keys/changes", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_key_changes_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_key_changes::Request<'_>>,
|
||||
|
|
|
@ -12,6 +12,7 @@ use std::convert::TryInto;
|
|||
const MXC_LENGTH: usize = 32;
|
||||
|
||||
#[cfg_attr(feature = "conduit_bin", get("/_matrix/media/r0/config"))]
|
||||
#[tracing::instrument(skip(db))]
|
||||
pub async fn get_media_config_route(
|
||||
db: State<'_, Database>,
|
||||
) -> ConduitResult<get_media_config::Response> {
|
||||
|
@ -25,6 +26,7 @@ pub async fn get_media_config_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/media/r0/upload", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn create_content_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<create_content::Request<'_>>,
|
||||
|
@ -54,6 +56,7 @@ pub async fn create_content_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/media/r0/download/<_>/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_content_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_content::Request<'_>>,
|
||||
|
@ -103,6 +106,7 @@ pub async fn get_content_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/media/r0/thumbnail/<_>/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_content_thumbnail_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_content_thumbnail::Request<'_>>,
|
||||
|
|
|
@ -36,6 +36,7 @@ use rocket::{get, post};
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/rooms/<_>/join", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn join_room_by_id_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<join_room_by_id::Request<'_>>,
|
||||
|
@ -54,6 +55,7 @@ pub async fn join_room_by_id_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/join/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn join_room_by_id_or_alias_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<join_room_by_id_or_alias::Request<'_>>,
|
||||
|
@ -88,6 +90,7 @@ pub async fn join_room_by_id_or_alias_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/rooms/<_>/leave", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn leave_room_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<leave_room::Request<'_>>,
|
||||
|
@ -140,6 +143,7 @@ pub async fn leave_room_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/rooms/<_>/invite", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn invite_user_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<invite_user::Request<'_>>,
|
||||
|
@ -183,6 +187,7 @@ pub async fn invite_user_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/rooms/<_>/kick", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn kick_user_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<kick_user::Request<'_>>,
|
||||
|
@ -236,6 +241,7 @@ pub async fn kick_user_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/rooms/<_>/ban", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn ban_user_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<ban_user::Request<'_>>,
|
||||
|
@ -296,6 +302,7 @@ pub async fn ban_user_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/rooms/<_>/unban", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn unban_user_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<unban_user::Request<'_>>,
|
||||
|
@ -348,6 +355,7 @@ pub async fn unban_user_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/rooms/<_>/forget", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn forget_room_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<forget_room::Request<'_>>,
|
||||
|
@ -365,6 +373,7 @@ pub async fn forget_room_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/joined_rooms", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn joined_rooms_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<joined_rooms::Request>,
|
||||
|
@ -385,6 +394,7 @@ pub async fn joined_rooms_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/rooms/<_>/members", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_member_events_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_member_events::Request<'_>>,
|
||||
|
@ -414,6 +424,7 @@ pub async fn get_member_events_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/rooms/<_>/joined_members", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn joined_members_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<joined_members::Request<'_>>,
|
||||
|
|
|
@ -17,6 +17,7 @@ use rocket::{get, put};
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/r0/rooms/<_>/send/<_>/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn send_message_event_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<send_message_event::Request<'_>>,
|
||||
|
@ -88,6 +89,7 @@ pub async fn send_message_event_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/rooms/<_>/messages", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_message_events_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_message_events::Request<'_>>,
|
||||
|
|
|
@ -75,6 +75,7 @@ const SESSION_ID_LENGTH: usize = 256;
|
|||
|
||||
#[cfg(feature = "conduit_bin")]
|
||||
#[options("/<_..>")]
|
||||
#[tracing::instrument]
|
||||
pub async fn options_route() -> ConduitResult<send_event_to_device::Response> {
|
||||
Ok(send_event_to_device::Response.into())
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ use rocket::put;
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/r0/presence/<_>/status", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_presence_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<set_presence::Request<'_>>,
|
||||
|
|
|
@ -19,6 +19,7 @@ use std::convert::TryInto;
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/r0/profile/<_>/displayname", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_displayname_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<set_display_name::Request<'_>>,
|
||||
|
@ -102,6 +103,7 @@ pub async fn set_displayname_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/profile/<_>/displayname", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_displayname_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_display_name::Request<'_>>,
|
||||
|
@ -116,6 +118,7 @@ pub async fn get_displayname_route(
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/r0/profile/<_>/avatar_url", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_avatar_url_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<set_avatar_url::Request<'_>>,
|
||||
|
@ -199,6 +202,7 @@ pub async fn set_avatar_url_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/profile/<_>/avatar_url", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_avatar_url_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_avatar_url::Request<'_>>,
|
||||
|
@ -213,6 +217,7 @@ pub async fn get_avatar_url_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/profile/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_profile_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_profile::Request<'_>>,
|
||||
|
|
|
@ -22,6 +22,7 @@ use rocket::{delete, get, post, put};
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/pushrules", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_pushrules_all_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_pushrules_all::Request>,
|
||||
|
@ -46,6 +47,7 @@ pub async fn get_pushrules_all_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/pushrules/<_>/<_>/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_pushrule_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_pushrule::Request<'_>>,
|
||||
|
@ -101,6 +103,7 @@ pub async fn get_pushrule_route(
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/r0/pushrules/<_>/<_>/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_pushrule_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<set_pushrule::Request<'_>>,
|
||||
|
@ -247,6 +250,7 @@ pub async fn set_pushrule_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/pushrules/<_>/<_>/<_>/actions", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_pushrule_actions_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_pushrule_actions::Request<'_>>,
|
||||
|
@ -310,6 +314,7 @@ pub async fn get_pushrule_actions_route(
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/r0/pushrules/<_>/<_>/<_>/actions", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_pushrule_actions_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<set_pushrule_actions::Request<'_>>,
|
||||
|
@ -413,6 +418,7 @@ pub async fn set_pushrule_actions_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/pushrules/<_>/<_>/<_>/enabled", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_pushrule_enabled_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_pushrule_enabled::Request<'_>>,
|
||||
|
@ -473,6 +479,7 @@ pub async fn get_pushrule_enabled_route(
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/r0/pushrules/<_>/<_>/<_>/enabled", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_pushrule_enabled_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<set_pushrule_enabled::Request<'_>>,
|
||||
|
@ -576,6 +583,7 @@ pub async fn set_pushrule_enabled_route(
|
|||
feature = "conduit_bin",
|
||||
delete("/_matrix/client/r0/pushrules/<_>/<_>/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_pushrule_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<delete_pushrule::Request<'_>>,
|
||||
|
@ -666,6 +674,7 @@ pub async fn delete_pushrule_route(
|
|||
}
|
||||
|
||||
#[cfg_attr(feature = "conduit_bin", get("/_matrix/client/r0/pushers"))]
|
||||
#[tracing::instrument]
|
||||
pub async fn get_pushers_route() -> ConduitResult<get_pushers::Response> {
|
||||
Ok(get_pushers::Response {
|
||||
pushers: Vec::new(),
|
||||
|
@ -674,6 +683,7 @@ pub async fn get_pushers_route() -> ConduitResult<get_pushers::Response> {
|
|||
}
|
||||
|
||||
#[cfg_attr(feature = "conduit_bin", post("/_matrix/client/r0/pushers/set"))]
|
||||
#[tracing::instrument(skip(db))]
|
||||
pub async fn set_pushers_route(db: State<'_, Database>) -> ConduitResult<get_pushers::Response> {
|
||||
db.flush().await?;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ use std::{collections::BTreeMap, time::SystemTime};
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/rooms/<_>/read_markers", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn set_read_marker_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<set_read_marker::Request<'_>>,
|
||||
|
@ -84,6 +85,7 @@ pub async fn set_read_marker_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/rooms/<_>/receipt/<_>/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn create_receipt_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<create_receipt::Request<'_>>,
|
||||
|
|
|
@ -12,6 +12,7 @@ use rocket::put;
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/r0/rooms/<_>/redact/<_>/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn redact_event_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<redact_event::Request<'_>>,
|
||||
|
|
|
@ -22,6 +22,7 @@ use rocket::{get, post};
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/createRoom", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn create_room_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<create_room::Request<'_>>,
|
||||
|
@ -350,6 +351,7 @@ pub async fn create_room_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/rooms/<_>/event/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_room_event_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_room_event::Request<'_>>,
|
||||
|
@ -377,6 +379,7 @@ pub async fn get_room_event_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/rooms/<_room_id>/upgrade", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn upgrade_room_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<upgrade_room::Request<'_>>,
|
||||
|
|
|
@ -11,6 +11,7 @@ use std::collections::BTreeMap;
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/search", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn search_events_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<search_events::Request<'_>>,
|
||||
|
|
|
@ -24,6 +24,7 @@ use rocket::{get, post};
|
|||
/// Get the homeserver's supported login types. One of these should be used as the `type` field
|
||||
/// when logging in.
|
||||
#[cfg_attr(feature = "conduit_bin", get("/_matrix/client/r0/login"))]
|
||||
#[tracing::instrument]
|
||||
pub async fn get_login_types_route() -> ConduitResult<get_login_types::Response> {
|
||||
Ok(get_login_types::Response::new(vec![get_login_types::LoginType::Password]).into())
|
||||
}
|
||||
|
@ -42,6 +43,7 @@ pub async fn get_login_types_route() -> ConduitResult<get_login_types::Response>
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/login", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn login_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<login::Request<'_>>,
|
||||
|
@ -156,6 +158,7 @@ pub async fn login_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/logout", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn logout_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<logout::Request>,
|
||||
|
@ -183,6 +186,7 @@ pub async fn logout_route(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/logout/all", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn logout_all_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<logout_all::Request>,
|
||||
|
|
|
@ -22,6 +22,7 @@ use rocket::{get, put};
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/r0/rooms/<_>/state/<_>/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn send_state_event_for_key_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<send_state_event_for_key::Request<'_>>,
|
||||
|
@ -55,6 +56,7 @@ pub async fn send_state_event_for_key_route(
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/r0/rooms/<_>/state/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn send_state_event_for_empty_key_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<send_state_event_for_empty_key::Request<'_>>,
|
||||
|
@ -96,6 +98,7 @@ pub async fn send_state_event_for_empty_key_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/rooms/<_>/state", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_state_events_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_state_events::Request<'_>>,
|
||||
|
@ -142,6 +145,7 @@ pub async fn get_state_events_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/rooms/<_>/state/<_>/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_state_events_for_key_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_state_events_for_key::Request<'_>>,
|
||||
|
@ -193,6 +197,7 @@ pub async fn get_state_events_for_key_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/rooms/<_>/state/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_state_events_for_empty_key_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_state_events_for_empty_key::Request<'_>>,
|
||||
|
|
|
@ -30,6 +30,7 @@ use std::{
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/sync", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn sync_events_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<sync_events::Request<'_>>,
|
||||
|
@ -310,8 +311,7 @@ pub async fn sync_events_route(
|
|||
};
|
||||
|
||||
let state_events = if joined_since_last_sync {
|
||||
db.rooms
|
||||
.room_state_full(&room_id)?
|
||||
current_state
|
||||
.into_iter()
|
||||
.map(|(_, pdu)| pdu.to_sync_state_event())
|
||||
.collect()
|
||||
|
@ -708,6 +708,7 @@ pub async fn sync_events_route(
|
|||
Ok(response.into())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(db))]
|
||||
fn share_encrypted_room(
|
||||
db: &Database,
|
||||
sender_user: &UserId,
|
||||
|
|
|
@ -13,6 +13,7 @@ use rocket::{delete, get, put};
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/r0/user/<_>/rooms/<_>/tags/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn update_tag_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<create_tag::Request<'_>>,
|
||||
|
@ -49,6 +50,7 @@ pub async fn update_tag_route(
|
|||
feature = "conduit_bin",
|
||||
delete("/_matrix/client/r0/user/<_>/rooms/<_>/tags/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn delete_tag_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<delete_tag::Request<'_>>,
|
||||
|
@ -82,6 +84,7 @@ pub async fn delete_tag_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/user/<_>/rooms/<_>/tags", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_tags_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_tags::Request<'_>>,
|
||||
|
|
|
@ -10,6 +10,7 @@ use std::collections::BTreeMap;
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/thirdparty/protocols")
|
||||
)]
|
||||
#[tracing::instrument]
|
||||
pub async fn get_protocols_route() -> ConduitResult<get_protocols::Response> {
|
||||
warn!("TODO: get_protocols_route");
|
||||
Ok(get_protocols::Response {
|
||||
|
|
|
@ -12,6 +12,7 @@ use rocket::put;
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/r0/sendToDevice/<_>/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn send_event_to_device_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<send_event_to_device::Request<'_>>,
|
||||
|
|
|
@ -10,6 +10,7 @@ use rocket::put;
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/client/r0/rooms/<_>/typing/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub fn create_typing_event_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<create_typing_event::Request<'_>>,
|
||||
|
|
|
@ -15,6 +15,7 @@ use rocket::get;
|
|||
/// Note: Unstable features are used while developing new features. Clients should avoid using
|
||||
/// unstable features in their stable releases
|
||||
#[cfg_attr(feature = "conduit_bin", get("/_matrix/client/versions"))]
|
||||
#[tracing::instrument]
|
||||
pub async fn get_supported_versions_route() -> ConduitResult<get_supported_versions::Response> {
|
||||
let mut resp =
|
||||
get_supported_versions::Response::new(vec!["r0.5.0".to_owned(), "r0.6.0".to_owned()]);
|
||||
|
|
|
@ -9,6 +9,7 @@ use rocket::post;
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/user_directory/search", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn search_users_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<search_users::Request<'_>>,
|
||||
|
|
|
@ -6,6 +6,7 @@ use std::time::Duration;
|
|||
use rocket::get;
|
||||
|
||||
#[cfg_attr(feature = "conduit_bin", get("/_matrix/client/r0/voip/turnServer"))]
|
||||
#[tracing::instrument]
|
||||
pub async fn turn_server_route() -> ConduitResult<get_turn_server_info::Response> {
|
||||
Ok(get_turn_server_info::Response {
|
||||
username: "".to_owned(),
|
||||
|
|
|
@ -38,6 +38,8 @@ pub struct Config {
|
|||
allow_encryption: bool,
|
||||
#[serde(default = "false_fn")]
|
||||
allow_federation: bool,
|
||||
#[serde(default = "false_fn")]
|
||||
pub allow_jaeger: bool,
|
||||
jwt_secret: Option<String>,
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ impl AccountData {
|
|||
}
|
||||
|
||||
/// Returns all changes to the account data that happened after `since`.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn changes_since(
|
||||
&self,
|
||||
room_id: Option<&RoomId>,
|
||||
|
|
|
@ -108,6 +108,7 @@ impl StateStore for Rooms {
|
|||
impl Rooms {
|
||||
/// Builds a StateMap by iterating over all keys that start
|
||||
/// with state_hash, this gives the full state for the given state_hash.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn state_full(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
|
@ -145,6 +146,7 @@ impl Rooms {
|
|||
}
|
||||
|
||||
/// Returns a single PDU from `room_id` with key (`event_type`, `state_key`).
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn state_get(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
|
@ -186,11 +188,13 @@ impl Rooms {
|
|||
}
|
||||
|
||||
/// Returns the last state hash key added to the db.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn pdu_state_hash(&self, pdu_id: &[u8]) -> Result<Option<StateHashId>> {
|
||||
Ok(self.pduid_statehash.get(pdu_id)?)
|
||||
}
|
||||
|
||||
/// Returns the last state hash key added to the db for the given room.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn current_state_hash(&self, room_id: &RoomId) -> Result<Option<StateHashId>> {
|
||||
Ok(self.roomid_statehash.get(room_id.as_bytes())?)
|
||||
}
|
||||
|
@ -290,6 +294,7 @@ impl Rooms {
|
|||
}
|
||||
|
||||
/// Returns the full room state.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn room_state_full(&self, room_id: &RoomId) -> Result<StateMap<PduEvent>> {
|
||||
if let Some(current_state_hash) = self.current_state_hash(room_id)? {
|
||||
self.state_full(&room_id, ¤t_state_hash)
|
||||
|
@ -299,6 +304,7 @@ impl Rooms {
|
|||
}
|
||||
|
||||
/// Returns a single PDU from `room_id` with key (`event_type`, `state_key`).
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn room_state_get(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
|
@ -313,6 +319,7 @@ impl Rooms {
|
|||
}
|
||||
|
||||
/// Returns the `count` of this pdu's id.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn pdu_count(&self, pdu_id: &[u8]) -> Result<u64> {
|
||||
Ok(
|
||||
utils::u64_from_bytes(&pdu_id[pdu_id.len() - mem::size_of::<u64>()..pdu_id.len()])
|
||||
|
@ -1024,6 +1031,7 @@ impl Rooms {
|
|||
}
|
||||
|
||||
/// Returns an iterator over all PDUs in a room.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn all_pdus(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
|
@ -1034,6 +1042,7 @@ impl Rooms {
|
|||
|
||||
/// Returns a double-ended iterator over all events in a room that happened after the event with id `since`
|
||||
/// in chronological order.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn pdus_since(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
|
@ -1100,6 +1109,7 @@ impl Rooms {
|
|||
|
||||
/// Returns an iterator over all events and their token in a room that happened after the event
|
||||
/// with id `from` in chronological order.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn pdus_after(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
|
@ -1449,6 +1459,7 @@ impl Rooms {
|
|||
))
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn get_shared_rooms<'a>(
|
||||
&'a self,
|
||||
users: Vec<UserId>,
|
||||
|
@ -1510,6 +1521,7 @@ impl Rooms {
|
|||
}
|
||||
|
||||
/// Returns an iterator over all joined members of a room.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn room_members(&self, room_id: &RoomId) -> impl Iterator<Item = Result<UserId>> {
|
||||
let mut prefix = room_id.as_bytes().to_vec();
|
||||
prefix.push(0xff);
|
||||
|
@ -1558,6 +1570,7 @@ impl Rooms {
|
|||
}
|
||||
|
||||
/// Returns an iterator over all invited members of a room.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn room_members_invited(&self, room_id: &RoomId) -> impl Iterator<Item = Result<UserId>> {
|
||||
let mut prefix = room_id.as_bytes().to_vec();
|
||||
prefix.push(0xff);
|
||||
|
@ -1582,6 +1595,7 @@ impl Rooms {
|
|||
}
|
||||
|
||||
/// Returns an iterator over all rooms this user joined.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn rooms_joined(&self, user_id: &UserId) -> impl Iterator<Item = Result<RoomId>> {
|
||||
self.userroomid_joined
|
||||
.scan_prefix(user_id.as_bytes())
|
||||
|
@ -1603,6 +1617,7 @@ impl Rooms {
|
|||
}
|
||||
|
||||
/// Returns an iterator over all rooms a user was invited to.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn rooms_invited(&self, user_id: &UserId) -> impl Iterator<Item = Result<RoomId>> {
|
||||
let mut prefix = user_id.as_bytes().to_vec();
|
||||
prefix.push(0xff);
|
||||
|
@ -1627,6 +1642,7 @@ impl Rooms {
|
|||
}
|
||||
|
||||
/// Returns an iterator over all rooms a user left.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn rooms_left(&self, user_id: &UserId) -> impl Iterator<Item = Result<RoomId>> {
|
||||
let mut prefix = user_id.as_bytes().to_vec();
|
||||
prefix.push(0xff);
|
||||
|
|
|
@ -71,6 +71,7 @@ impl RoomEdus {
|
|||
}
|
||||
|
||||
/// Returns an iterator over the most recent read_receipts in a room that happened after the event with id `since`.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn readreceipts_since(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
|
@ -116,6 +117,7 @@ impl RoomEdus {
|
|||
}
|
||||
|
||||
/// Returns the private read marker.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn private_read_get(&self, room_id: &RoomId, user_id: &UserId) -> Result<Option<u64>> {
|
||||
let mut key = room_id.to_string().as_bytes().to_vec();
|
||||
key.push(0xff);
|
||||
|
@ -257,6 +259,7 @@ impl RoomEdus {
|
|||
}
|
||||
|
||||
/// Returns the count of the last typing update in this room.
|
||||
#[tracing::instrument(skip(self, globals))]
|
||||
pub fn last_typing_update(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
|
@ -340,6 +343,7 @@ impl RoomEdus {
|
|||
}
|
||||
|
||||
/// Resets the presence timeout, so the user will stay in their current presence state.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn ping_presence(&self, user_id: &UserId) -> Result<()> {
|
||||
self.userid_lastpresenceupdate.insert(
|
||||
&user_id.to_string().as_bytes(),
|
||||
|
@ -430,6 +434,7 @@ impl RoomEdus {
|
|||
}
|
||||
|
||||
/// Returns an iterator over the most recent presence updates that happened after the event with id `since`.
|
||||
#[tracing::instrument(skip(self, globals, rooms))]
|
||||
pub fn presence_since(
|
||||
&self,
|
||||
room_id: &RoomId,
|
||||
|
|
|
@ -235,6 +235,7 @@ impl Sending {
|
|||
});
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn send_pdu(&self, server: &ServerName, pdu_id: &[u8]) -> Result<()> {
|
||||
let mut key = server.as_bytes().to_vec();
|
||||
key.push(0xff);
|
||||
|
@ -244,6 +245,7 @@ impl Sending {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn send_pdu_appservice(&self, appservice_id: &str, pdu_id: &[u8]) -> Result<()> {
|
||||
let mut key = "+".as_bytes().to_vec();
|
||||
key.extend_from_slice(appservice_id.as_bytes());
|
||||
|
@ -254,6 +256,7 @@ impl Sending {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
fn calculate_hash(keys: &[IVec]) -> Vec<u8> {
|
||||
// We only hash the pdu's event ids, not the whole pdu
|
||||
let bytes = keys.join(&0xff);
|
||||
|
@ -261,6 +264,7 @@ impl Sending {
|
|||
hash.as_ref().to_owned()
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(globals, rooms, appservice))]
|
||||
async fn handle_event(
|
||||
server: Box<ServerName>,
|
||||
is_appservice: bool,
|
||||
|
@ -397,6 +401,7 @@ impl Sending {
|
|||
))
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self, globals))]
|
||||
pub async fn send_federation_request<T: OutgoingRequest>(
|
||||
&self,
|
||||
globals: &crate::database::globals::Globals,
|
||||
|
@ -413,6 +418,7 @@ impl Sending {
|
|||
response
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self, globals))]
|
||||
pub async fn send_appservice_request<T: OutgoingRequest>(
|
||||
&self,
|
||||
globals: &crate::database::globals::Globals,
|
||||
|
|
|
@ -312,6 +312,7 @@ impl Users {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn last_one_time_keys_update(&self, user_id: &UserId) -> Result<u64> {
|
||||
self.userid_lastonetimekeyupdate
|
||||
.get(&user_id.to_string().as_bytes())?
|
||||
|
@ -365,6 +366,7 @@ impl Users {
|
|||
.transpose()
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn count_one_time_keys(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
|
@ -564,6 +566,7 @@ impl Users {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn keys_changed(
|
||||
&self,
|
||||
user_or_room_id: &str,
|
||||
|
@ -739,6 +742,7 @@ impl Users {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn get_to_device_events(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
|
@ -761,6 +765,7 @@ impl Users {
|
|||
Ok(events)
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn remove_to_device_events(
|
||||
&self,
|
||||
user_id: &UserId,
|
||||
|
|
68
src/error.rs
68
src/error.rs
|
@ -1,14 +1,7 @@
|
|||
use std::{collections::HashMap, sync::RwLock, time::Duration, time::Instant};
|
||||
|
||||
use log::error;
|
||||
use ruma::{
|
||||
api::client::{error::ErrorKind, r0::uiaa::UiaaInfo},
|
||||
events::room::message,
|
||||
};
|
||||
use ruma::api::client::{error::ErrorKind, r0::uiaa::UiaaInfo};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::{database::admin::AdminCommand, Database};
|
||||
|
||||
#[cfg(feature = "conduit_bin")]
|
||||
use {
|
||||
crate::RumaResponse,
|
||||
|
@ -107,62 +100,3 @@ where
|
|||
.respond_to(r)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ConduitLogger {
|
||||
pub db: Database,
|
||||
pub last_logs: RwLock<HashMap<String, Instant>>,
|
||||
}
|
||||
|
||||
impl log::Log for ConduitLogger {
|
||||
fn enabled(&self, _metadata: &log::Metadata<'_>) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn log(&self, record: &log::Record<'_>) {
|
||||
let output = format!("{} - {}", record.level(), record.args());
|
||||
|
||||
if self.enabled(record.metadata())
|
||||
&& (record
|
||||
.module_path()
|
||||
.map_or(false, |path| path.starts_with("conduit::"))
|
||||
|| record
|
||||
.module_path()
|
||||
.map_or(true, |path| !path.starts_with("rocket::")) // Rockets logs are annoying
|
||||
&& record.metadata().level() <= log::Level::Warn)
|
||||
{
|
||||
let first_line = output
|
||||
.lines()
|
||||
.next()
|
||||
.expect("lines always returns one item");
|
||||
|
||||
eprintln!("{}", output);
|
||||
|
||||
let mute_duration = match record.metadata().level() {
|
||||
log::Level::Error => Duration::from_secs(60 * 5), // 5 minutes
|
||||
log::Level::Warn => Duration::from_secs(60 * 60 * 24), // A day
|
||||
_ => Duration::from_secs(60 * 60 * 24 * 7), // A week
|
||||
};
|
||||
|
||||
if self
|
||||
.last_logs
|
||||
.read()
|
||||
.unwrap()
|
||||
.get(first_line)
|
||||
.map_or(false, |i| i.elapsed() < mute_duration)
|
||||
// Don't post this log again for some time
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if let Ok(mut_last_logs) = &mut self.last_logs.try_write() {
|
||||
mut_last_logs.insert(first_line.to_owned(), Instant::now());
|
||||
}
|
||||
|
||||
self.db.admin.send(AdminCommand::SendMessage(
|
||||
message::MessageEventContent::notice_plain(output),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
fn flush(&self) {}
|
||||
}
|
||||
|
|
52
src/main.rs
52
src/main.rs
|
@ -11,21 +11,23 @@ mod push_rules;
|
|||
mod ruma_wrapper;
|
||||
mod utils;
|
||||
|
||||
use database::Config;
|
||||
pub use database::Database;
|
||||
pub use error::{ConduitLogger, Error, Result};
|
||||
pub use error::{Error, Result};
|
||||
pub use pdu::PduEvent;
|
||||
pub use rocket::State;
|
||||
use ruma::api::client::error::ErrorKind;
|
||||
pub use ruma_wrapper::{ConduitResult, Ruma, RumaResponse};
|
||||
|
||||
use log::LevelFilter;
|
||||
use rocket::figment::{
|
||||
providers::{Env, Format, Toml},
|
||||
Figment,
|
||||
};
|
||||
use rocket::{catch, catchers, fairing::AdHoc, routes, Request};
|
||||
use tracing::span;
|
||||
use tracing_subscriber::{prelude::*, Registry};
|
||||
|
||||
fn setup_rocket() -> rocket::Rocket {
|
||||
fn setup_rocket() -> (rocket::Rocket, Config) {
|
||||
// Force log level off, so we can use our own logger
|
||||
std::env::set_var("CONDUIT_LOG_LEVEL", "off");
|
||||
|
||||
|
@ -39,7 +41,12 @@ fn setup_rocket() -> rocket::Rocket {
|
|||
)
|
||||
.merge(Env::prefixed("CONDUIT_").global());
|
||||
|
||||
rocket::custom(config)
|
||||
let parsed_config = config
|
||||
.extract::<Config>()
|
||||
.expect("It looks like your config is invalid. Please take a look at the error");
|
||||
let parsed_config2 = parsed_config.clone();
|
||||
|
||||
let rocket = rocket::custom(config)
|
||||
.mount(
|
||||
"/",
|
||||
routes![
|
||||
|
@ -163,30 +170,41 @@ fn setup_rocket() -> rocket::Rocket {
|
|||
bad_json_catcher
|
||||
])
|
||||
.attach(AdHoc::on_attach("Config", |rocket| async {
|
||||
let config = rocket
|
||||
.figment()
|
||||
.extract()
|
||||
.expect("It looks like your config is invalid. Please take a look at the error");
|
||||
let data = Database::load_or_create(config)
|
||||
let data = Database::load_or_create(parsed_config2)
|
||||
.await
|
||||
.expect("config is valid");
|
||||
|
||||
data.sending
|
||||
.start_handler(&data.globals, &data.rooms, &data.appservice);
|
||||
log::set_boxed_logger(Box::new(ConduitLogger {
|
||||
db: data.clone(),
|
||||
last_logs: Default::default(),
|
||||
}))
|
||||
.unwrap();
|
||||
log::set_max_level(LevelFilter::Info);
|
||||
|
||||
Ok(rocket.manage(data))
|
||||
}))
|
||||
}));
|
||||
|
||||
(rocket, parsed_config)
|
||||
}
|
||||
|
||||
#[rocket::main]
|
||||
async fn main() {
|
||||
setup_rocket().launch().await.unwrap();
|
||||
let (rocket, config) = setup_rocket();
|
||||
|
||||
if config.allow_jaeger {
|
||||
let (tracer, _uninstall) = opentelemetry_jaeger::new_pipeline()
|
||||
.with_service_name("conduit")
|
||||
.install()
|
||||
.unwrap();
|
||||
let telemetry = tracing_opentelemetry::layer().with_tracer(tracer);
|
||||
Registry::default().with(telemetry).try_init().unwrap();
|
||||
|
||||
let root = span!(tracing::Level::INFO, "app_start", work_units = 2);
|
||||
let _enter = root.enter();
|
||||
|
||||
rocket.launch().await.unwrap();
|
||||
} else {
|
||||
let root = span!(tracing::Level::INFO, "app_start", work_units = 2);
|
||||
let _enter = root.enter();
|
||||
|
||||
rocket.launch().await.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[catch(404)]
|
||||
|
|
34
src/pdu.rs
34
src/pdu.rs
|
@ -40,6 +40,7 @@ pub struct PduEvent {
|
|||
}
|
||||
|
||||
impl PduEvent {
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn redact(&mut self, reason: &PduEvent) -> crate::Result<()> {
|
||||
self.unsigned.clear();
|
||||
|
||||
|
@ -86,6 +87,7 @@ impl PduEvent {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn to_sync_room_event(&self) -> Raw<AnySyncRoomEvent> {
|
||||
let mut json = json!({
|
||||
"content": self.content,
|
||||
|
@ -107,6 +109,7 @@ impl PduEvent {
|
|||
}
|
||||
|
||||
/// This only works for events that are also AnyRoomEvents.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn to_any_event(&self) -> Raw<AnyEvent> {
|
||||
let mut json = json!({
|
||||
"content": self.content,
|
||||
|
@ -128,6 +131,7 @@ impl PduEvent {
|
|||
serde_json::from_value(json).expect("Raw::from_value always works")
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn to_room_event(&self) -> Raw<AnyRoomEvent> {
|
||||
let mut json = json!({
|
||||
"content": self.content,
|
||||
|
@ -149,6 +153,7 @@ impl PduEvent {
|
|||
serde_json::from_value(json).expect("Raw::from_value always works")
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn to_state_event(&self) -> Raw<AnyStateEvent> {
|
||||
let json = json!({
|
||||
"content": self.content,
|
||||
|
@ -164,20 +169,27 @@ impl PduEvent {
|
|||
serde_json::from_value(json).expect("Raw::from_value always works")
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn to_sync_state_event(&self) -> Raw<AnySyncStateEvent> {
|
||||
let json = json!({
|
||||
"content": self.content,
|
||||
"type": self.kind,
|
||||
"event_id": self.event_id,
|
||||
"sender": self.sender,
|
||||
"origin_server_ts": self.origin_server_ts,
|
||||
"unsigned": self.unsigned,
|
||||
"state_key": self.state_key,
|
||||
});
|
||||
let json = format!(
|
||||
r#"{{"content":{},"type":"{}","event_id":"{}","sender":"{}","origin_server_ts":{},"unsigned":{},"state_key":"{}"}}"#,
|
||||
self.content,
|
||||
self.kind,
|
||||
self.event_id,
|
||||
self.sender,
|
||||
self.origin_server_ts,
|
||||
serde_json::to_string(&self.unsigned).expect("Map::to_string always works"),
|
||||
self.state_key
|
||||
.as_ref()
|
||||
.expect("state events have state keys")
|
||||
);
|
||||
|
||||
serde_json::from_value(json).expect("Raw::from_value always works")
|
||||
Raw::from_json(
|
||||
serde_json::value::RawValue::from_string(json).expect("our string is valid json"),
|
||||
)
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn to_stripped_state_event(&self) -> Raw<AnyStrippedStateEvent> {
|
||||
let json = json!({
|
||||
"content": self.content,
|
||||
|
@ -189,6 +201,7 @@ impl PduEvent {
|
|||
serde_json::from_value(json).expect("Raw::from_value always works")
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn to_member_event(&self) -> Raw<StateEvent<MemberEventContent>> {
|
||||
let json = json!({
|
||||
"content": self.content,
|
||||
|
@ -206,6 +219,7 @@ impl PduEvent {
|
|||
}
|
||||
|
||||
/// This does not return a full `Pdu` it is only to satisfy ruma's types.
|
||||
#[tracing::instrument]
|
||||
pub fn convert_to_outgoing_federation_event(
|
||||
mut pdu_json: CanonicalJsonObject,
|
||||
) -> Raw<ruma::events::pdu::Pdu> {
|
||||
|
|
|
@ -28,6 +28,7 @@ use std::{
|
|||
time::{Duration, SystemTime},
|
||||
};
|
||||
|
||||
#[tracing::instrument(skip(globals))]
|
||||
pub async fn send_request<T: OutgoingRequest>(
|
||||
globals: &crate::database::globals::Globals,
|
||||
destination: Box<ServerName>,
|
||||
|
@ -194,6 +195,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
fn get_ip_with_port(destination_str: String) -> Option<String> {
|
||||
if destination_str.parse::<SocketAddr>().is_ok() {
|
||||
Some(destination_str)
|
||||
|
@ -204,6 +206,7 @@ fn get_ip_with_port(destination_str: String) -> Option<String> {
|
|||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
fn add_port_to_hostname(destination_str: String) -> String {
|
||||
match destination_str.find(':') {
|
||||
None => destination_str.to_owned() + ":8448",
|
||||
|
@ -214,6 +217,7 @@ fn add_port_to_hostname(destination_str: String) -> String {
|
|||
/// Returns: actual_destination, host header
|
||||
/// Implemented according to the specification at https://matrix.org/docs/spec/server_server/r0.1.4#resolving-server-names
|
||||
/// Numbers in comments below refer to bullet points in linked section of specification
|
||||
#[tracing::instrument(skip(globals))]
|
||||
async fn find_actual_destination(
|
||||
globals: &crate::database::globals::Globals,
|
||||
destination: &Box<ServerName>,
|
||||
|
@ -272,6 +276,7 @@ async fn find_actual_destination(
|
|||
(actual_destination, host)
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(globals))]
|
||||
async fn query_srv_record<'a>(
|
||||
globals: &crate::database::globals::Globals,
|
||||
hostname: &'a str,
|
||||
|
@ -296,6 +301,7 @@ async fn query_srv_record<'a>(
|
|||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(globals))]
|
||||
pub async fn request_well_known(
|
||||
globals: &crate::database::globals::Globals,
|
||||
destination: &str,
|
||||
|
@ -319,6 +325,7 @@ pub async fn request_well_known(
|
|||
}
|
||||
|
||||
#[cfg_attr(feature = "conduit_bin", get("/_matrix/federation/v1/version"))]
|
||||
#[tracing::instrument(skip(db))]
|
||||
pub fn get_server_version_route(
|
||||
db: State<'_, Database>,
|
||||
) -> ConduitResult<get_server_version::Response> {
|
||||
|
@ -336,6 +343,7 @@ pub fn get_server_version_route(
|
|||
}
|
||||
|
||||
#[cfg_attr(feature = "conduit_bin", get("/_matrix/key/v2/server"))]
|
||||
#[tracing::instrument(skip(db))]
|
||||
pub fn get_server_keys_route(db: State<'_, Database>) -> Json<String> {
|
||||
if !db.globals.allow_federation() {
|
||||
// TODO: Use proper types
|
||||
|
@ -378,6 +386,7 @@ pub fn get_server_keys_route(db: State<'_, Database>) -> Json<String> {
|
|||
}
|
||||
|
||||
#[cfg_attr(feature = "conduit_bin", get("/_matrix/key/v2/server/<_>"))]
|
||||
#[tracing::instrument(skip(db))]
|
||||
pub fn get_server_keys_deprecated_route(db: State<'_, Database>) -> Json<String> {
|
||||
get_server_keys_route(db)
|
||||
}
|
||||
|
@ -386,6 +395,7 @@ pub fn get_server_keys_deprecated_route(db: State<'_, Database>) -> Json<String>
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/federation/v1/publicRooms", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_public_rooms_filtered_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_public_rooms_filtered::v1::Request<'_>>,
|
||||
|
@ -433,6 +443,7 @@ pub async fn get_public_rooms_filtered_route(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/federation/v1/publicRooms", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn get_public_rooms_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_public_rooms::v1::Request<'_>>,
|
||||
|
@ -480,6 +491,7 @@ pub async fn get_public_rooms_route(
|
|||
feature = "conduit_bin",
|
||||
put("/_matrix/federation/v1/send/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn send_transaction_message_route<'a>(
|
||||
db: State<'a, Database>,
|
||||
body: Ruma<send_transaction_message::v1::Request<'_>>,
|
||||
|
@ -585,6 +597,7 @@ pub async fn send_transaction_message_route<'a>(
|
|||
feature = "conduit_bin",
|
||||
post("/_matrix/federation/v1/get_missing_events/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub fn get_missing_events_route<'a>(
|
||||
db: State<'a, Database>,
|
||||
body: Ruma<get_missing_events::v1::Request<'_>>,
|
||||
|
@ -630,6 +643,7 @@ pub fn get_missing_events_route<'a>(
|
|||
feature = "conduit_bin",
|
||||
get("/_matrix/federation/v1/query/profile", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub fn get_profile_information_route<'a>(
|
||||
db: State<'a, Database>,
|
||||
body: Ruma<get_profile_information::v1::Request<'_>>,
|
||||
|
|
Loading…
Reference in New Issue