diff --git a/.gitignore b/.gitignore
index 1f5f395f848dab8b5be5fdfe9d0e685a796c5975..f5e9505b8c4e0ba56a4f938f6d41a428a284680d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -57,7 +57,6 @@ $RECYCLE.BIN/
*.lnk
# Conduit
-Rocket.toml
conduit.toml
conduit.db
diff --git a/Cargo.lock b/Cargo.lock
index 794a0257dcb0b7a86ff66c3cf9a8f725eff7382f..8c31fef8ca5d026cb659828493805db399268410 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,6 +2,12 @@
# It is not intended for manual editing.
version = 3
+[[package]]
+name = "adler"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
+
[[package]]
name = "adler32"
version = "1.2.0"
@@ -28,6 +34,21 @@ dependencies = [
"memchr",
]
+[[package]]
+name = "alloc-no-stdlib"
+version = "2.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "35ef4730490ad1c4eae5c4325b2a95f521d023e5c885853ff7aca0a6a1631db3"
+
+[[package]]
+name = "alloc-stdlib"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "697ed7edc0f1711de49ce108c541623a0af97c6c60b2f6e2b65229847ac843c2"
+dependencies = [
+ "alloc-no-stdlib",
+]
+
[[package]]
name = "ansi_term"
version = "0.12.1"
@@ -37,6 +58,12 @@ dependencies = [
"winapi",
]
+[[package]]
+name = "arc-swap"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c5d78ce20460b82d3fa150275ed9d55e21064fc7951177baacf86a145c4a4b1f"
+
[[package]]
name = "arrayref"
version = "0.3.6"
@@ -56,24 +83,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f093eed78becd229346bf859eec0aa4dd7ddde0757287b2b4107a1f09c80002"
[[package]]
-name = "async-stream"
-version = "0.3.2"
+name = "async-compression"
+version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "171374e7e3b2504e0e5236e3b59260560f9fe94bfe9ac39ba5e4e929c5590625"
+checksum = "5443ccbb270374a2b1055fc72da40e1f237809cd6bb0e97e66d264cd138473a6"
dependencies = [
- "async-stream-impl",
+ "brotli",
+ "flate2",
"futures-core",
-]
-
-[[package]]
-name = "async-stream-impl"
-version = "0.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "648ed8c8d2ce5409ccd57453d9d1b214b342a0d69376a6feda1fd6cae3299308"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
+ "memchr",
+ "pin-project-lite",
+ "tokio",
]
[[package]]
@@ -97,27 +117,76 @@ dependencies = [
]
[[package]]
-name = "atty"
-version = "0.2.14"
+name = "autocfg"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
+
+[[package]]
+name = "axum"
+version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
+checksum = "310a147401c66e79fc78636e4db63ac68cd6acb9ece056de806ea173a15bce32"
dependencies = [
- "hermit-abi",
- "libc",
- "winapi",
+ "async-trait",
+ "axum-core",
+ "bitflags",
+ "bytes",
+ "futures-util",
+ "headers",
+ "http",
+ "http-body",
+ "hyper",
+ "matchit",
+ "memchr",
+ "mime",
+ "percent-encoding",
+ "pin-project-lite",
+ "serde",
+ "serde_json",
+ "serde_urlencoded",
+ "sync_wrapper",
+ "tokio",
+ "tokio-util",
+ "tower",
+ "tower-http",
+ "tower-layer",
+ "tower-service",
]
[[package]]
-name = "autocfg"
-version = "1.0.1"
+name = "axum-core"
+version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
+checksum = "1ca6c0b218388a7ed6a8d25e94f7dea5498daaa4fd8c711fb3ff166041b06fda"
+dependencies = [
+ "async-trait",
+ "bytes",
+ "futures-util",
+ "http",
+ "http-body",
+ "mime",
+]
[[package]]
-name = "base-x"
-version = "0.2.8"
+name = "axum-server"
+version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b"
+checksum = "f9cfd9dbe28ebde5c0460067ea27c6f3b1d514b699c4e0a5aab0fb63e452a8a8"
+dependencies = [
+ "arc-swap",
+ "bytes",
+ "futures-util",
+ "http",
+ "http-body",
+ "hyper",
+ "pin-project-lite",
+ "rustls",
+ "rustls-pemfile",
+ "tokio",
+ "tokio-rustls",
+ "tower-service",
+]
[[package]]
name = "base64"
@@ -131,12 +200,6 @@ version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
-[[package]]
-name = "binascii"
-version = "0.1.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "383d29d513d8764dcdc42ea295d979eb99c3c9f00607b3692cf68a431f7dca72"
-
[[package]]
name = "bincode"
version = "1.3.3"
@@ -191,6 +254,27 @@ dependencies = [
"generic-array",
]
+[[package]]
+name = "brotli"
+version = "3.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f838e47a451d5a8fa552371f80024dd6ace9b7acdf25c4c3d0f9bc6816fb1c39"
+dependencies = [
+ "alloc-no-stdlib",
+ "alloc-stdlib",
+ "brotli-decompressor",
+]
+
+[[package]]
+name = "brotli-decompressor"
+version = "2.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "59ad2d4653bf5ca36ae797b1f4bb4dbddb60ce49ca4aed8a2ce4829f60425b80"
+dependencies = [
+ "alloc-no-stdlib",
+ "alloc-stdlib",
+]
+
[[package]]
name = "bumpalo"
version = "3.9.1"
@@ -254,7 +338,7 @@ dependencies = [
"libc",
"num-integer",
"num-traits",
- "time 0.1.43",
+ "time",
"winapi",
]
@@ -279,10 +363,14 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
name = "conduit"
version = "0.2.0"
dependencies = [
+ "axum",
+ "axum-server",
"base64 0.13.0",
"bytes",
"crossbeam",
"directories",
+ "figment",
+ "futures-util",
"heed",
"hmac",
"http",
@@ -298,7 +386,6 @@ dependencies = [
"regex",
"reqwest",
"ring",
- "rocket",
"rocksdb",
"ruma",
"rusqlite",
@@ -314,9 +401,11 @@ dependencies = [
"tikv-jemalloc-ctl",
"tikv-jemallocator",
"tokio",
+ "tower",
+ "tower-http",
"tracing",
"tracing-flame",
- "tracing-subscriber 0.2.25",
+ "tracing-subscriber",
"trust-dns-resolver",
]
@@ -326,29 +415,12 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b"
-[[package]]
-name = "const_fn"
-version = "0.4.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935"
-
[[package]]
name = "constant_time_eq"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
-[[package]]
-name = "cookie"
-version = "0.15.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d5f1c7727e460397e56abc4bddc1d49e07a1ad78fc98eb2e1c8f032a58a2f80d"
-dependencies = [
- "percent-encoding",
- "time 0.2.27",
- "version_check",
-]
-
[[package]]
name = "cpufeatures"
version = "0.2.1"
@@ -517,39 +589,6 @@ dependencies = [
"const-oid",
]
-[[package]]
-name = "devise"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "50c7580b072f1c8476148f16e0a0d5dedddab787da98d86c5082c5e9ed8ab595"
-dependencies = [
- "devise_codegen",
- "devise_core",
-]
-
-[[package]]
-name = "devise_codegen"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "123c73e7a6e51b05c75fe1a1b2f4e241399ea5740ed810b0e3e6cacd9db5e7b2"
-dependencies = [
- "devise_core",
- "quote",
-]
-
-[[package]]
-name = "devise_core"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "841ef46f4787d9097405cac4e70fb8644fc037b526e8c14054247c0263c400d0"
-dependencies = [
- "bitflags",
- "proc-macro2",
- "proc-macro2-diagnostics",
- "quote",
- "syn",
-]
-
[[package]]
name = "digest"
version = "0.9.0"
@@ -579,12 +618,6 @@ dependencies = [
"winapi",
]
-[[package]]
-name = "discard"
-version = "1.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0"
-
[[package]]
name = "ed25519"
version = "1.3.0"
@@ -647,15 +680,6 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
-[[package]]
-name = "fastrand"
-version = "1.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "779d043b6a0b90cc4c0ed7ee380a6504394cee7efd7db050e3774eee387324b2"
-dependencies = [
- "instant",
-]
-
[[package]]
name = "figment"
version = "0.10.6"
@@ -670,6 +694,18 @@ dependencies = [
"version_check",
]
+[[package]]
+name = "flate2"
+version = "1.0.22"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f"
+dependencies = [
+ "cfg-if 1.0.0",
+ "crc32fast",
+ "libc",
+ "miniz_oxide 0.4.4",
+]
+
[[package]]
name = "fnv"
version = "1.0.7"
@@ -800,19 +836,6 @@ dependencies = [
"byteorder",
]
-[[package]]
-name = "generator"
-version = "0.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c1d9279ca822891c1a4dae06d185612cf8fc6acfe5dff37781b41297811b12ee"
-dependencies = [
- "cc",
- "libc",
- "log",
- "rustversion",
- "winapi",
-]
-
[[package]]
name = "generic-array"
version = "0.14.5"
@@ -898,6 +921,31 @@ dependencies = [
"hashbrown",
]
+[[package]]
+name = "headers"
+version = "0.3.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a4c4eb0471fcb85846d8b0690695ef354f9afb11cb03cac2e1d7c9253351afb0"
+dependencies = [
+ "base64 0.13.0",
+ "bitflags",
+ "bytes",
+ "headers-core",
+ "http",
+ "httpdate",
+ "mime",
+ "sha-1",
+]
+
+[[package]]
+name = "headers-core"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429"
+dependencies = [
+ "http",
+]
+
[[package]]
name = "heck"
version = "0.3.3"
@@ -995,6 +1043,12 @@ dependencies = [
"pin-project-lite",
]
+[[package]]
+name = "http-range-header"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29"
+
[[package]]
name = "httparse"
version = "1.5.1"
@@ -1039,9 +1093,9 @@ checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac"
dependencies = [
"http",
"hyper",
- "rustls 0.20.2",
+ "rustls",
"tokio",
- "tokio-rustls 0.23.2",
+ "tokio-rustls",
]
[[package]]
@@ -1285,21 +1339,6 @@ dependencies = [
"cfg-if 1.0.0",
]
-[[package]]
-name = "loom"
-version = "0.5.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "edc5c7d328e32cc4954e8e01193d7f0ef5ab257b5090b70a964e099a36034309"
-dependencies = [
- "cfg-if 1.0.0",
- "generator",
- "scoped-tls",
- "serde",
- "serde_json",
- "tracing",
- "tracing-subscriber 0.3.6",
-]
-
[[package]]
name = "lru-cache"
version = "0.1.2"
@@ -1330,21 +1369,18 @@ dependencies = [
"regex-automata",
]
-[[package]]
-name = "matchers"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
-dependencies = [
- "regex-automata",
-]
-
[[package]]
name = "matches"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
+[[package]]
+name = "matchit"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "58b6f41fdfbec185dd3dff58b51e323f5bc61692c0de38419a957b0dcfccca3c"
+
[[package]]
name = "memchr"
version = "2.4.1"
@@ -1381,6 +1417,16 @@ dependencies = [
"adler32",
]
+[[package]]
+name = "miniz_oxide"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b"
+dependencies = [
+ "adler",
+ "autocfg",
+]
+
[[package]]
name = "mio"
version = "0.7.14"
@@ -1403,26 +1449,6 @@ dependencies = [
"winapi",
]
-[[package]]
-name = "multer"
-version = "2.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5f8f35e687561d5c1667590911e6698a8cb714a134a7505718a182e7bc9d3836"
-dependencies = [
- "bytes",
- "encoding_rs",
- "futures-util",
- "http",
- "httparse",
- "log",
- "memchr",
- "mime",
- "spin 0.9.2",
- "tokio",
- "tokio-util",
- "version_check",
-]
-
[[package]]
name = "nom"
version = "7.1.0"
@@ -1730,7 +1756,7 @@ dependencies = [
"bitflags",
"crc32fast",
"deflate",
- "miniz_oxide",
+ "miniz_oxide 0.3.7",
]
[[package]]
@@ -1749,12 +1775,6 @@ dependencies = [
"toml",
]
-[[package]]
-name = "proc-macro-hack"
-version = "0.5.19"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
-
[[package]]
name = "proc-macro2"
version = "1.0.36"
@@ -1892,26 +1912,6 @@ dependencies = [
"redox_syscall",
]
-[[package]]
-name = "ref-cast"
-version = "1.0.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "300f2a835d808734ee295d45007adacb9ebb29dd3ae2424acfa17930cae541da"
-dependencies = [
- "ref-cast-impl",
-]
-
-[[package]]
-name = "ref-cast-impl"
-version = "1.0.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c38e3aecd2b21cb3959637b883bb3714bc7e43f0268b9a29d3743ee3e55cdd2"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
-]
-
[[package]]
name = "regex"
version = "1.5.4"
@@ -1938,15 +1938,6 @@ version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
-[[package]]
-name = "remove_dir_all"
-version = "0.5.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
-dependencies = [
- "winapi",
-]
-
[[package]]
name = "reqwest"
version = "0.11.9"
@@ -1970,13 +1961,13 @@ dependencies = [
"mime",
"percent-encoding",
"pin-project-lite",
- "rustls 0.20.2",
+ "rustls",
"rustls-pemfile",
"serde",
"serde_json",
"serde_urlencoded",
"tokio",
- "tokio-rustls 0.23.2",
+ "tokio-rustls",
"tokio-socks",
"url",
"wasm-bindgen",
@@ -2005,98 +1996,15 @@ dependencies = [
"cc",
"libc",
"once_cell",
- "spin 0.5.2",
+ "spin",
"untrusted",
"web-sys",
"winapi",
]
[[package]]
-name = "rocket"
-version = "0.5.0-rc.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0a71c18c42a0eb15bf3816831caf0dad11e7966f2a41aaf486a701979c4dd1f2"
-dependencies = [
- "async-stream",
- "async-trait",
- "atomic",
- "atty",
- "binascii",
- "bytes",
- "either",
- "figment",
- "futures",
- "indexmap",
- "log",
- "memchr",
- "multer",
- "num_cpus",
- "parking_lot",
- "pin-project-lite",
- "rand 0.8.4",
- "ref-cast",
- "rocket_codegen",
- "rocket_http",
- "serde",
- "state",
- "tempfile",
- "time 0.2.27",
- "tokio",
- "tokio-stream",
- "tokio-util",
- "ubyte",
- "version_check",
- "yansi",
-]
-
-[[package]]
-name = "rocket_codegen"
-version = "0.5.0-rc.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "66f5fa462f7eb958bba8710c17c5d774bbbd59809fa76fb1957af7e545aea8bb"
-dependencies = [
- "devise",
- "glob",
- "indexmap",
- "proc-macro2",
- "quote",
- "rocket_http",
- "syn",
- "unicode-xid",
-]
-
-[[package]]
-name = "rocket_http"
-version = "0.5.0-rc.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "23c8b7d512d2fcac2316ebe590cde67573844b99e6cc9ee0f53375fa16e25ebd"
-dependencies = [
- "cookie",
- "either",
- "http",
- "hyper",
- "indexmap",
- "log",
- "memchr",
- "mime",
- "parking_lot",
- "pear",
- "percent-encoding",
- "pin-project-lite",
- "ref-cast",
- "serde",
- "smallvec",
- "stable-pattern",
- "state",
- "time 0.2.27",
- "tokio",
- "tokio-rustls 0.22.0",
- "uncased",
-]
-
-[[package]]
-name = "rocksdb"
-version = "0.17.0"
+name = "rocksdb"
+version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a62eca5cacf2c8261128631bed9f045598d40bfbe4b29f5163f0f802f8f44a7"
dependencies = [
@@ -2398,28 +2306,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
-[[package]]
-name = "rustc_version"
-version = "0.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
-dependencies = [
- "semver",
-]
-
-[[package]]
-name = "rustls"
-version = "0.19.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7"
-dependencies = [
- "base64 0.13.0",
- "log",
- "ring",
- "sct 0.6.1",
- "webpki 0.21.4",
-]
-
[[package]]
name = "rustls"
version = "0.20.2"
@@ -2428,8 +2314,8 @@ checksum = "d37e5e2290f3e040b594b1a9e04377c2c671f1a1cfd9bfdef82106ac1c113f84"
dependencies = [
"log",
"ring",
- "sct 0.7.0",
- "webpki 0.22.0",
+ "sct",
+ "webpki",
]
[[package]]
@@ -2441,40 +2327,18 @@ dependencies = [
"base64 0.13.0",
]
-[[package]]
-name = "rustversion"
-version = "1.0.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f"
-
[[package]]
name = "ryu"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f"
-[[package]]
-name = "scoped-tls"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
-
[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
-[[package]]
-name = "sct"
-version = "0.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce"
-dependencies = [
- "ring",
- "untrusted",
-]
-
[[package]]
name = "sct"
version = "0.7.0"
@@ -2485,21 +2349,6 @@ dependencies = [
"untrusted",
]
-[[package]]
-name = "semver"
-version = "0.9.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
-dependencies = [
- "semver-parser",
-]
-
-[[package]]
-name = "semver-parser"
-version = "0.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
-
[[package]]
name = "serde"
version = "1.0.134"
@@ -2568,21 +2417,6 @@ dependencies = [
"opaque-debug",
]
-[[package]]
-name = "sha1"
-version = "0.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770"
-dependencies = [
- "sha1_smol",
-]
-
-[[package]]
-name = "sha1_smol"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012"
-
[[package]]
name = "sha2"
version = "0.9.9"
@@ -2693,12 +2527,6 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
-[[package]]
-name = "spin"
-version = "0.9.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "511254be0c5bcf062b019a6c89c01a664aa359ded62f78aa72c6fc137c0590e5"
-
[[package]]
name = "spki"
version = "0.4.1"
@@ -2708,82 +2536,6 @@ dependencies = [
"der",
]
-[[package]]
-name = "stable-pattern"
-version = "0.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4564168c00635f88eaed410d5efa8131afa8d8699a612c80c455a0ba05c21045"
-dependencies = [
- "memchr",
-]
-
-[[package]]
-name = "standback"
-version = "0.2.17"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff"
-dependencies = [
- "version_check",
-]
-
-[[package]]
-name = "state"
-version = "0.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "87cf4f5369e6d3044b5e365c9690f451516ac8f0954084622b49ea3fde2f6de5"
-dependencies = [
- "loom",
-]
-
-[[package]]
-name = "stdweb"
-version = "0.4.20"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5"
-dependencies = [
- "discard",
- "rustc_version",
- "stdweb-derive",
- "stdweb-internal-macros",
- "stdweb-internal-runtime",
- "wasm-bindgen",
-]
-
-[[package]]
-name = "stdweb-derive"
-version = "0.5.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef"
-dependencies = [
- "proc-macro2",
- "quote",
- "serde",
- "serde_derive",
- "syn",
-]
-
-[[package]]
-name = "stdweb-internal-macros"
-version = "0.2.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11"
-dependencies = [
- "base-x",
- "proc-macro2",
- "quote",
- "serde",
- "serde_derive",
- "serde_json",
- "sha1",
- "syn",
-]
-
-[[package]]
-name = "stdweb-internal-runtime"
-version = "0.1.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0"
-
[[package]]
name = "subtle"
version = "2.4.1"
@@ -2801,6 +2553,12 @@ dependencies = [
"unicode-xid",
]
+[[package]]
+name = "sync_wrapper"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "20518fe4a4c9acf048008599e464deb21beeae3d3578418951a189c235a7a9a8"
+
[[package]]
name = "synchronoise"
version = "1.0.0"
@@ -2822,20 +2580,6 @@ dependencies = [
"unicode-xid",
]
-[[package]]
-name = "tempfile"
-version = "3.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
-dependencies = [
- "cfg-if 1.0.0",
- "fastrand",
- "libc",
- "redox_syscall",
- "remove_dir_all",
- "winapi",
-]
-
[[package]]
name = "thiserror"
version = "1.0.30"
@@ -2929,44 +2673,6 @@ dependencies = [
"winapi",
]
-[[package]]
-name = "time"
-version = "0.2.27"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242"
-dependencies = [
- "const_fn",
- "libc",
- "standback",
- "stdweb",
- "time-macros",
- "version_check",
- "winapi",
-]
-
-[[package]]
-name = "time-macros"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1"
-dependencies = [
- "proc-macro-hack",
- "time-macros-impl",
-]
-
-[[package]]
-name = "time-macros-impl"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f"
-dependencies = [
- "proc-macro-hack",
- "proc-macro2",
- "quote",
- "standback",
- "syn",
-]
-
[[package]]
name = "tinyvec"
version = "1.5.1"
@@ -3011,26 +2717,15 @@ dependencies = [
"syn",
]
-[[package]]
-name = "tokio-rustls"
-version = "0.22.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
-dependencies = [
- "rustls 0.19.1",
- "tokio",
- "webpki 0.21.4",
-]
-
[[package]]
name = "tokio-rustls"
version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a27d5f2b839802bd8267fa19b0530f5a08b9c08cd417976be2a65d130fe1c11b"
dependencies = [
- "rustls 0.20.2",
+ "rustls",
"tokio",
- "webpki 0.22.0",
+ "webpki",
]
[[package]]
@@ -3079,6 +2774,52 @@ dependencies = [
"serde",
]
+[[package]]
+name = "tower"
+version = "0.4.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5651b5f6860a99bd1adb59dbfe1db8beb433e73709d9032b413a77e2fb7c066a"
+dependencies = [
+ "futures-core",
+ "futures-util",
+ "pin-project",
+ "pin-project-lite",
+ "tokio",
+ "tokio-util",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+]
+
+[[package]]
+name = "tower-http"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "03650267ad175b51c47d02ed9547fc7d4ba2c7e5cb76df0bed67edd1825ae297"
+dependencies = [
+ "async-compression",
+ "bitflags",
+ "bytes",
+ "futures-core",
+ "futures-util",
+ "http",
+ "http-body",
+ "http-range-header",
+ "pin-project-lite",
+ "tokio",
+ "tokio-util",
+ "tower",
+ "tower-layer",
+ "tower-service",
+ "tracing",
+]
+
+[[package]]
+name = "tower-layer"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "343bc9466d3fe6b0f960ef45960509f84480bf4fd96f92901afe7ff3df9d3a62"
+
[[package]]
name = "tower-service"
version = "0.3.1"
@@ -3092,6 +2833,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105"
dependencies = [
"cfg-if 1.0.0",
+ "log",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
@@ -3125,7 +2867,7 @@ checksum = "bd520fe41c667b437952383f3a1ec14f1fa45d653f719a77eedd6e6a02d8fa54"
dependencies = [
"lazy_static",
"tracing",
- "tracing-subscriber 0.2.25",
+ "tracing-subscriber",
]
[[package]]
@@ -3158,7 +2900,7 @@ dependencies = [
"ansi_term",
"chrono",
"lazy_static",
- "matchers 0.0.1",
+ "matchers",
"regex",
"serde",
"serde_json",
@@ -3171,24 +2913,6 @@ dependencies = [
"tracing-serde",
]
-[[package]]
-name = "tracing-subscriber"
-version = "0.3.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "77be66445c4eeebb934a7340f227bfe7b338173d3f8c00a60a5a58005c9faecf"
-dependencies = [
- "ansi_term",
- "lazy_static",
- "matchers 0.1.0",
- "regex",
- "sharded-slab",
- "smallvec",
- "thread_local",
- "tracing",
- "tracing-core",
- "tracing-log",
-]
-
[[package]]
name = "trust-dns-proto"
version = "0.20.3"
@@ -3246,22 +2970,12 @@ version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
-[[package]]
-name = "ubyte"
-version = "0.10.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "42756bb9e708855de2f8a98195643dff31a97f0485d90d8467b39dc24be9e8fe"
-dependencies = [
- "serde",
-]
-
[[package]]
name = "uncased"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5baeed7327e25054889b9bd4f975f32e5f4c5d434042d59ab6cd4142c0a76ed0"
dependencies = [
- "serde",
"version_check",
]
@@ -3441,16 +3155,6 @@ dependencies = [
"wasm-bindgen",
]
-[[package]]
-name = "webpki"
-version = "0.21.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea"
-dependencies = [
- "ring",
- "untrusted",
-]
-
[[package]]
name = "webpki"
version = "0.22.0"
@@ -3467,7 +3171,7 @@ version = "0.22.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "552ceb903e957524388c4d3475725ff2c8b7960922063af6ce53c9a43da07449"
dependencies = [
- "webpki 0.22.0",
+ "webpki",
]
[[package]]
diff --git a/Cargo.toml b/Cargo.toml
index 9ba1ac05c8960ac14a16a18e4481707089b8a862..823012b84fc4c18f1fbcf90ca642249ce66354dc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,10 +13,11 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-# Used to handle requests
-# TODO: This can become optional as soon as proper configs are supported
-# rocket = { git = "https://github.com/SergioBenitez/Rocket.git", rev = "801e04bd5369eb39e126c75f6d11e1e9597304d8", features = ["tls"] } # Used to handle requests
-rocket = { version = "0.5.0-rc.1", features = ["tls"] } # Used to handle requests
+# Web framework
+axum = { version = "0.4.4", features = ["headers"], optional = true }
+axum-server = { version = "0.3.3", features = ["tls-rustls"] }
+tower = { version = "0.4.11", features = ["util"] }
+tower-http = { version = "0.2.1", features = ["add-extension", "cors", "compression-full", "sensitive-headers", "trace", "util"] }
# Used for matrix spec type definitions and helpers
#ruma = { version = "0.4.0", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
@@ -24,8 +25,8 @@ ruma = { git = "https://github.com/ruma/ruma", rev = "82becb86c83757022496442592
#ruma = { git = "https://github.com/timokoesters/ruma", rev = "50c1db7e0a3a21fc794b0cce3b64285a4c750c71", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
#ruma = { path = "../ruma/crates/ruma", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
-# Used for long polling and federation sender, should be the same as rocket::tokio
-tokio = "1.11.0"
+# Async runtime and utilities
+tokio = { version = "1.11.0", features = ["fs", "macros", "signal", "sync"] }
# Used for storing data permanently
sled = { version = "0.34.6", features = ["compression", "no_metrics"], optional = true }
#sled = { git = "https://github.com/spacejam/sled.git", rev = "e4640e0773595229f398438886f19bca6f7326a2", features = ["compression"] }
@@ -33,7 +34,6 @@ persy = { version = "1.2" , optional = true, features=["background_ops"] }
# Used for the http request / response body type for Ruma endpoints used with reqwest
bytes = "1.1.0"
-# Used for rocket<->ruma conversions
http = "0.2.4"
# Used to find data directory for default db path
directories = "3.0.2"
@@ -82,6 +82,9 @@ thread_local = "1.1.3"
# used for TURN server authentication
hmac = "0.11.0"
sha-1 = "0.9.8"
+futures-util = { version = "0.3.19", default-features = false }
+# Used for reading the configuration from conduit.toml & environment variables
+figment = { version = "0.10.6", features = ["env", "toml"] }
[target.'cfg(not(target_env = "msvc"))'.dependencies]
tikv-jemalloc-ctl = { version = "0.4.2", features = ['use_std'] }
@@ -95,7 +98,7 @@ backend_sqlite = ["sqlite"]
backend_heed = ["heed", "crossbeam"]
backend_rocksdb = ["rocksdb"]
sqlite = ["rusqlite", "parking_lot", "tokio/signal"]
-conduit_bin = [] # TODO: add rocket to this when it is optional
+conduit_bin = ["axum"]
[[bin]]
name = "conduit"
diff --git a/README.md b/README.md
index e667d18da71adf0250e0ba728a7ed078231fb701..2095c868a927901338da249680684c1ccc19d8fa 100644
--- a/README.md
+++ b/README.md
@@ -58,7 +58,7 @@ Thanks to Famedly, Prototype Fund (DLR and German BMBF) and all other individual
Thanks to the contributors to Conduit and all libraries we use, for example:
- Ruma: A clean library for the Matrix Spec in Rust
-- Rocket: A flexible web framework
+- axum: A modular web framework
#### Donate
diff --git a/conduit-example.toml b/conduit-example.toml
index c0274a4df8fb31abc1e44c755935046089046b3f..ce9d929c2d56be5dcc819390a475353298e4c3be 100644
--- a/conduit-example.toml
+++ b/conduit-example.toml
@@ -41,7 +41,7 @@ allow_registration = true
trusted_servers = ["matrix.org"]
#max_concurrent_requests = 100 # How many requests Conduit sends to other servers at the same time
-#log = "info,state_res=warn,rocket=off,_=off,sled=off"
+#log = "info,state_res=warn,_=off,sled=off"
#workers = 4 # default: cpu core count * 2
address = "127.0.0.1" # This makes sure Conduit can only be reached using the reverse proxy
diff --git a/debian/postinst b/debian/postinst
index 6bd1a3a723421d7b31e9efe08ec7113411c03c35..29a936765060490989ab98564da71b248624720f 100644
--- a/debian/postinst
+++ b/debian/postinst
@@ -74,7 +74,7 @@ allow_registration = true
#allow_jaeger = false
#max_concurrent_requests = 100 # How many requests Conduit sends to other servers at the same time
-#log = "info,state_res=warn,rocket=off,_=off,sled=off"
+#log = "info,state_res=warn,_=off,sled=off"
#workers = 4 # default: cpu core count * 2
# The total amount of memory that the database will use.
diff --git a/docker-compose.yml b/docker-compose.yml
index 530fc1988aa3c3333a342c618ff0d62573bc6fd8..88d5c3f62c8c330e104171c53fa4c3571647947f 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -33,7 +33,7 @@ services:
# CONDUIT_PORT: 6167
# CONDUIT_CONFIG: '/srv/conduit/conduit.toml' # if you want to configure purely by env vars, set this to an empty string ''
# Available levels are: error, warn, info, debug, trace - more info at: https://docs.rs/env_logger/*/env_logger/#enabling-logging
- # CONDUIT_LOG: info # default is: "info,rocket=off,_=off,sled=off"
+ # CONDUIT_LOG: info # default is: "info,_=off,sled=off"
# CONDUIT_ALLOW_JAEGER: 'false'
# CONDUIT_ALLOW_ENCRYPTION: 'false'
# CONDUIT_ALLOW_FEDERATION: 'false'
diff --git a/docker/docker-compose.traefik.yml b/docker/docker-compose.traefik.yml
index 392b3828968f644b8f507a619fabda420962b6b3..f625080a68710a1038cbf0e3bb5a4f4b4da351c9 100644
--- a/docker/docker-compose.traefik.yml
+++ b/docker/docker-compose.traefik.yml
@@ -33,7 +33,7 @@ services:
# CONDUIT_PORT: 6167
# CONDUIT_CONFIG: '/srv/conduit/conduit.toml' # if you want to configure purely by env vars, set this to an empty string ''
# Available levels are: error, warn, info, debug, trace - more info at: https://docs.rs/env_logger/*/env_logger/#enabling-logging
- # CONDUIT_LOG: info # default is: "info,rocket=off,_=off,sled=off"
+ # CONDUIT_LOG: info # default is: "info,_=off,sled=off"
# CONDUIT_ALLOW_JAEGER: 'false'
# CONDUIT_ALLOW_ENCRYPTION: 'false'
# CONDUIT_ALLOW_FEDERATION: 'false'
diff --git a/src/client_server/account.rs b/src/client_server/account.rs
index c4e118c9cdcf78dbeb3b9ab44333393b897518d4..e2d4bd26958851d6102c09043580ac8104f05646 100644
--- a/src/client_server/account.rs
+++ b/src/client_server/account.rs
@@ -1,7 +1,7 @@
use std::{collections::BTreeMap, convert::TryInto, sync::Arc};
use super::{DEVICE_ID_LENGTH, SESSION_ID_LENGTH, TOKEN_LENGTH};
-use crate::{database::DatabaseGuard, pdu::PduBuilder, utils, ConduitResult, Error, Ruma};
+use crate::{database::DatabaseGuard, pdu::PduBuilder, utils, Error, Result, Ruma};
use ruma::{
api::client::{
error::ErrorKind,
@@ -35,8 +35,6 @@ use serde_json::value::to_raw_value;
use tracing::info;
use register::RegistrationKind;
-#[cfg(feature = "conduit_bin")]
-use rocket::{get, post};
const GUEST_NAME_LENGTH: usize = 10;
@@ -50,15 +48,11 @@ const GUEST_NAME_LENGTH: usize = 10;
/// - No user or appservice on this server already claimed this username
///
/// Note: This will not reserve the username, so the username might become invalid when trying to register
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/register/available", data = "
")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_register_available_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
// Validate user id
let user_id = UserId::parse_with_server_name(body.username.clone(), db.globals.server_name())
.ok()
@@ -81,7 +75,7 @@ pub async fn get_register_available_route(
// TODO add check for appservice namespaces
// If no if check is true we have an username that's available to be used.
- Ok(get_username_availability::Response { available: true }.into())
+ Ok(get_username_availability::Response { available: true })
}
/// # `POST /_matrix/client/r0/register`
@@ -97,15 +91,11 @@ pub async fn get_register_available_route(
/// - If type is not guest and no username is given: Always fails after UIAA check
/// - Creates a new account and populates it with default account data
/// - If `inhibit_login` is false: Creates a device and returns device id and access_token
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/r0/register", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn register_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
if !db.globals.allow_registration() && !body.from_appservice {
return Err(Error::BadRequest(
ErrorKind::Forbidden,
@@ -229,8 +219,7 @@ pub async fn register_route(
access_token: None,
user_id,
device_id: None,
- }
- .into());
+ });
}
// Generate new device id if the user didn't specify one
@@ -528,8 +517,7 @@ pub async fn register_route(
access_token: Some(token),
user_id,
device_id: Some(device_id),
- }
- .into())
+ })
}
/// # `POST /_matrix/client/r0/account/password`
@@ -546,15 +534,11 @@ pub async fn register_route(
/// - Deletes device metadata (device id, device display name, last seen ip, last seen ts)
/// - Forgets to-device events
/// - Triggers device list updates
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/r0/account/password", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn change_password_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
@@ -607,7 +591,7 @@ pub async fn change_password_route(
db.flush()?;
- Ok(change_password::Response {}.into())
+ Ok(change_password::Response {})
}
/// # `GET _matrix/client/r0/account/whoami`
@@ -615,17 +599,12 @@ pub async fn change_password_route(
/// Get user_id of the sender user.
///
/// Note: Also works for Application Services
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/account/whoami", data = "")
-)]
#[tracing::instrument(skip(body))]
-pub async fn whoami_route(body: Ruma) -> ConduitResult {
+pub async fn whoami_route(body: Ruma) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
Ok(whoami::Response {
user_id: sender_user.clone(),
- }
- .into())
+ })
}
/// # `POST /_matrix/client/r0/account/deactivate`
@@ -638,15 +617,11 @@ pub async fn whoami_route(body: Ruma) -> ConduitResult>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
@@ -741,8 +716,7 @@ pub async fn deactivate_route(
Ok(deactivate::Response {
id_server_unbind_result: ThirdPartyIdRemovalStatus::NoSupport,
- }
- .into())
+ })
}
/// # `GET _matrix/client/r0/account/3pid`
@@ -750,14 +724,8 @@ pub async fn deactivate_route(
/// Get a list of third party identifiers associated with this account.
///
/// - Currently always returns empty list
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/account/3pid", data = "")
-)]
-pub async fn third_party_route(
- body: Ruma,
-) -> ConduitResult {
+pub async fn third_party_route(body: Ruma) -> Result {
let _sender_user = body.sender_user.as_ref().expect("user is authenticated");
- Ok(get_3pids::Response::new(Vec::new()).into())
+ Ok(get_3pids::Response::new(Vec::new()))
}
diff --git a/src/client_server/alias.rs b/src/client_server/alias.rs
index 129ac1666f1959916a45be1e72478994daaba446..eecd72a4e4b88463bb415967b6afd48876106528 100644
--- a/src/client_server/alias.rs
+++ b/src/client_server/alias.rs
@@ -1,4 +1,4 @@
-use crate::{database::DatabaseGuard, ConduitResult, Database, Error, Ruma};
+use crate::{database::DatabaseGuard, Database, Error, Result, Ruma};
use regex::Regex;
use ruma::{
api::{
@@ -12,21 +12,14 @@ use ruma::{
RoomAliasId,
};
-#[cfg(feature = "conduit_bin")]
-use rocket::{delete, get, put};
-
/// # `PUT /_matrix/client/r0/directory/room/{roomAlias}`
///
/// Creates a new room alias on this server.
-#[cfg_attr(
- feature = "conduit_bin",
- put("/_matrix/client/r0/directory/room/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn create_alias_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
if body.room_alias.server_name() != db.globals.server_name() {
return Err(Error::BadRequest(
ErrorKind::InvalidParam,
@@ -43,7 +36,7 @@ pub async fn create_alias_route(
db.flush()?;
- Ok(create_alias::Response::new().into())
+ Ok(create_alias::Response::new())
}
/// # `DELETE /_matrix/client/r0/directory/room/{roomAlias}`
@@ -52,15 +45,11 @@ pub async fn create_alias_route(
///
/// - TODO: additional access control checks
/// - TODO: Update canonical alias event
-#[cfg_attr(
- feature = "conduit_bin",
- delete("/_matrix/client/r0/directory/room/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn delete_alias_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
if body.room_alias.server_name() != db.globals.server_name() {
return Err(Error::BadRequest(
ErrorKind::InvalidParam,
@@ -74,7 +63,7 @@ pub async fn delete_alias_route(
db.flush()?;
- Ok(delete_alias::Response::new().into())
+ Ok(delete_alias::Response::new())
}
/// # `GET /_matrix/client/r0/directory/room/{roomAlias}`
@@ -82,22 +71,18 @@ pub async fn delete_alias_route(
/// Resolve an alias locally or over federation.
///
/// - TODO: Suggest more servers to join via
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/directory/room/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_alias_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
get_alias_helper(&db, &body.room_alias).await
}
pub(crate) async fn get_alias_helper(
db: &Database,
room_alias: &RoomAliasId,
-) -> ConduitResult {
+) -> Result {
if room_alias.server_name() != db.globals.server_name() {
let response = db
.sending
@@ -108,7 +93,7 @@ pub(crate) async fn get_alias_helper(
)
.await?;
- return Ok(get_alias::Response::new(response.room_id, response.servers).into());
+ return Ok(get_alias::Response::new(response.room_id, response.servers));
}
let mut room_id = None;
@@ -159,5 +144,8 @@ pub(crate) async fn get_alias_helper(
}
};
- Ok(get_alias::Response::new(room_id, vec![db.globals.server_name().to_owned()]).into())
+ Ok(get_alias::Response::new(
+ room_id,
+ vec![db.globals.server_name().to_owned()],
+ ))
}
diff --git a/src/client_server/backup.rs b/src/client_server/backup.rs
index bbb86726158da3e1b9f4d89e49cb5079b0f387b5..acff437e46dea35c299c46b0f32071f011ddd1ca 100644
--- a/src/client_server/backup.rs
+++ b/src/client_server/backup.rs
@@ -1,4 +1,4 @@
-use crate::{database::DatabaseGuard, ConduitResult, Error, Ruma};
+use crate::{database::DatabaseGuard, Error, Result, Ruma};
use ruma::api::client::{
error::ErrorKind,
r0::backup::{
@@ -9,21 +9,14 @@ use ruma::api::client::{
},
};
-#[cfg(feature = "conduit_bin")]
-use rocket::{delete, get, post, put};
-
/// # `POST /_matrix/client/r0/room_keys/version`
///
/// Creates a new backup.
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/unstable/room_keys/version", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn create_backup_route(
db: DatabaseGuard,
body: Ruma,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let version = db
.key_backups
@@ -31,42 +24,34 @@ pub async fn create_backup_route(
db.flush()?;
- Ok(create_backup::Response { version }.into())
+ Ok(create_backup::Response { version })
}
/// # `PUT /_matrix/client/r0/room_keys/version/{version}`
///
/// Update information about an existing backup. Only `auth_data` can be modified.
-#[cfg_attr(
- feature = "conduit_bin",
- put("/_matrix/client/unstable/room_keys/version/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn update_backup_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
db.key_backups
.update_backup(sender_user, &body.version, &body.algorithm, &db.globals)?;
db.flush()?;
- Ok(update_backup::Response {}.into())
+ Ok(update_backup::Response {})
}
/// # `GET /_matrix/client/r0/room_keys/version`
///
/// Get information about the latest backup version.
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/unstable/room_keys/version", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_latest_backup_route(
db: DatabaseGuard,
body: Ruma,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let (version, algorithm) =
@@ -82,22 +67,17 @@ pub async fn get_latest_backup_route(
count: (db.key_backups.count_keys(sender_user, &version)? as u32).into(),
etag: db.key_backups.get_etag(sender_user, &version)?,
version,
- }
- .into())
+ })
}
/// # `GET /_matrix/client/r0/room_keys/version`
///
/// Get information about an existing backup.
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/unstable/room_keys/version/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_backup_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let algorithm = db
.key_backups
@@ -112,8 +92,7 @@ pub async fn get_backup_route(
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
etag: db.key_backups.get_etag(sender_user, &body.version)?,
version: body.version.to_owned(),
- }
- .into())
+ })
}
/// # `DELETE /_matrix/client/r0/room_keys/version/{version}`
@@ -121,22 +100,18 @@ pub async fn get_backup_route(
/// Delete an existing key backup.
///
/// - Deletes both information about the backup, as well as all key data related to the backup
-#[cfg_attr(
- feature = "conduit_bin",
- delete("/_matrix/client/unstable/room_keys/version/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn delete_backup_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
db.key_backups.delete_backup(sender_user, &body.version)?;
db.flush()?;
- Ok(delete_backup::Response {}.into())
+ Ok(delete_backup::Response {})
}
/// # `PUT /_matrix/client/r0/room_keys/keys`
@@ -146,15 +121,11 @@ pub async fn delete_backup_route(
/// - Only manipulating the most recently created version of the backup is allowed
/// - Adds the keys to the backup
/// - Returns the new number of keys in this backup and the etag
-#[cfg_attr(
- feature = "conduit_bin",
- put("/_matrix/client/unstable/room_keys/keys", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn add_backup_keys_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if Some(&body.version)
@@ -187,8 +158,7 @@ pub async fn add_backup_keys_route(
Ok(add_backup_keys::Response {
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
etag: db.key_backups.get_etag(sender_user, &body.version)?,
- }
- .into())
+ })
}
/// # `PUT /_matrix/client/r0/room_keys/keys/{roomId}`
@@ -198,15 +168,11 @@ pub async fn add_backup_keys_route(
/// - Only manipulating the most recently created version of the backup is allowed
/// - Adds the keys to the backup
/// - Returns the new number of keys in this backup and the etag
-#[cfg_attr(
- feature = "conduit_bin",
- put("/_matrix/client/unstable/room_keys/keys/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn add_backup_key_sessions_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if Some(&body.version)
@@ -237,8 +203,7 @@ pub async fn add_backup_key_sessions_route(
Ok(add_backup_key_sessions::Response {
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
etag: db.key_backups.get_etag(sender_user, &body.version)?,
- }
- .into())
+ })
}
/// # `PUT /_matrix/client/r0/room_keys/keys/{roomId}/{sessionId}`
@@ -248,15 +213,11 @@ pub async fn add_backup_key_sessions_route(
/// - Only manipulating the most recently created version of the backup is allowed
/// - Adds the keys to the backup
/// - Returns the new number of keys in this backup and the etag
-#[cfg_attr(
- feature = "conduit_bin",
- put("/_matrix/client/unstable/room_keys/keys/<_>/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn add_backup_key_session_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if Some(&body.version)
@@ -285,62 +246,49 @@ pub async fn add_backup_key_session_route(
Ok(add_backup_key_session::Response {
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
etag: db.key_backups.get_etag(sender_user, &body.version)?,
- }
- .into())
+ })
}
/// # `GET /_matrix/client/r0/room_keys/keys`
///
/// Retrieves all keys from the backup.
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/unstable/room_keys/keys", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_backup_keys_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let rooms = db.key_backups.get_all(sender_user, &body.version)?;
- Ok(get_backup_keys::Response { rooms }.into())
+ Ok(get_backup_keys::Response { rooms })
}
/// # `GET /_matrix/client/r0/room_keys/keys/{roomId}`
///
/// Retrieves all keys from the backup for a given room.
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/unstable/room_keys/keys/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_backup_key_sessions_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let sessions = db
.key_backups
.get_room(sender_user, &body.version, &body.room_id)?;
- Ok(get_backup_key_sessions::Response { sessions }.into())
+ Ok(get_backup_key_sessions::Response { sessions })
}
/// # `GET /_matrix/client/r0/room_keys/keys/{roomId}/{sessionId}`
///
/// Retrieves a key from the backup.
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/unstable/room_keys/keys/<_>/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_backup_key_session_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let key_data = db
@@ -351,21 +299,17 @@ pub async fn get_backup_key_session_route(
"Backup key not found for this user's session.",
))?;
- Ok(get_backup_key_session::Response { key_data }.into())
+ Ok(get_backup_key_session::Response { key_data })
}
/// # `DELETE /_matrix/client/r0/room_keys/keys`
///
/// Delete the keys from the backup.
-#[cfg_attr(
- feature = "conduit_bin",
- delete("/_matrix/client/unstable/room_keys/keys", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn delete_backup_keys_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
db.key_backups.delete_all_keys(sender_user, &body.version)?;
@@ -375,22 +319,17 @@ pub async fn delete_backup_keys_route(
Ok(delete_backup_keys::Response {
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
etag: db.key_backups.get_etag(sender_user, &body.version)?,
- }
- .into())
+ })
}
/// # `DELETE /_matrix/client/r0/room_keys/keys/{roomId}`
///
/// Delete the keys from the backup for a given room.
-#[cfg_attr(
- feature = "conduit_bin",
- delete("/_matrix/client/unstable/room_keys/keys/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn delete_backup_key_sessions_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
db.key_backups
@@ -401,22 +340,17 @@ pub async fn delete_backup_key_sessions_route(
Ok(delete_backup_key_sessions::Response {
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
etag: db.key_backups.get_etag(sender_user, &body.version)?,
- }
- .into())
+ })
}
/// # `DELETE /_matrix/client/r0/room_keys/keys/{roomId}/{sessionId}`
///
/// Delete a key from the backup.
-#[cfg_attr(
- feature = "conduit_bin",
- delete("/_matrix/client/unstable/room_keys/keys/<_>/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn delete_backup_key_session_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
db.key_backups
@@ -427,6 +361,5 @@ pub async fn delete_backup_key_session_route(
Ok(delete_backup_key_session::Response {
count: (db.key_backups.count_keys(sender_user, &body.version)? as u32).into(),
etag: db.key_backups.get_etag(sender_user, &body.version)?,
- }
- .into())
+ })
}
diff --git a/src/client_server/capabilities.rs b/src/client_server/capabilities.rs
index c69b7cb2349aad14b2a0b0cb8dd965d96e30011f..3f779dc33dae0cd822b70bf1cfc4f06dab832456 100644
--- a/src/client_server/capabilities.rs
+++ b/src/client_server/capabilities.rs
@@ -1,4 +1,4 @@
-use crate::{ConduitResult, Ruma};
+use crate::{Result, Ruma};
use ruma::{
api::client::r0::capabilities::{
get_capabilities, Capabilities, RoomVersionStability, RoomVersionsCapability,
@@ -7,20 +7,13 @@ use ruma::{
};
use std::collections::BTreeMap;
-#[cfg(feature = "conduit_bin")]
-use rocket::get;
-
/// # `GET /_matrix/client/r0/capabilities`
///
/// Get information on the supported feature set and other relevent capabilities of this server.
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/capabilities", data = "<_body>")
-)]
#[tracing::instrument(skip(_body))]
pub async fn get_capabilities_route(
_body: Ruma,
-) -> ConduitResult {
+) -> Result {
let mut available = BTreeMap::new();
available.insert(RoomVersionId::V5, RoomVersionStability::Stable);
available.insert(RoomVersionId::V6, RoomVersionStability::Stable);
@@ -31,5 +24,5 @@ pub async fn get_capabilities_route(
available,
};
- Ok(get_capabilities::Response { capabilities }.into())
+ Ok(get_capabilities::Response { capabilities })
}
diff --git a/src/client_server/config.rs b/src/client_server/config.rs
index 0c668ff1c097b14107fe6abde4269a9a114a1148..14a665ebeb66660ce63feacad2216b88f6c8cdde 100644
--- a/src/client_server/config.rs
+++ b/src/client_server/config.rs
@@ -1,4 +1,4 @@
-use crate::{database::DatabaseGuard, ConduitResult, Error, Ruma};
+use crate::{database::DatabaseGuard, Error, Result, Ruma};
use ruma::{
api::client::{
error::ErrorKind,
@@ -13,21 +13,14 @@ use ruma::{
use serde::Deserialize;
use serde_json::{json, value::RawValue as RawJsonValue};
-#[cfg(feature = "conduit_bin")]
-use rocket::{get, put};
-
/// # `PUT /_matrix/client/r0/user/{userId}/account_data/{type}`
///
/// Sets some account data for the sender user.
-#[cfg_attr(
- feature = "conduit_bin",
- put("/_matrix/client/r0/user/<_>/account_data/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn set_global_account_data_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let data: serde_json::Value = serde_json::from_str(body.data.get())
@@ -48,24 +41,17 @@ pub async fn set_global_account_data_route(
db.flush()?;
- Ok(set_global_account_data::Response {}.into())
+ Ok(set_global_account_data::Response {})
}
/// # `PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}`
///
/// Sets some room account data for the sender user.
-#[cfg_attr(
- feature = "conduit_bin",
- put(
- "/_matrix/client/r0/user/<_>/rooms/<_>/account_data/<_>",
- data = ""
- )
-)]
#[tracing::instrument(skip(db, body))]
pub async fn set_room_account_data_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let data: serde_json::Value = serde_json::from_str(body.data.get())
@@ -86,21 +72,17 @@ pub async fn set_room_account_data_route(
db.flush()?;
- Ok(set_room_account_data::Response {}.into())
+ Ok(set_room_account_data::Response {})
}
/// # `GET /_matrix/client/r0/user/{userId}/account_data/{type}`
///
/// Gets some account data for the sender user.
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/user/<_>/account_data/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_global_account_data_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let event: Box = db
@@ -112,24 +94,17 @@ pub async fn get_global_account_data_route(
.map_err(|_| Error::bad_database("Invalid account data event in db."))?
.content;
- Ok(get_global_account_data::Response { account_data }.into())
+ Ok(get_global_account_data::Response { account_data })
}
/// # `GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}`
///
/// Gets some room account data for the sender user.
-#[cfg_attr(
- feature = "conduit_bin",
- get(
- "/_matrix/client/r0/user/<_>/rooms/<_>/account_data/<_>",
- data = ""
- )
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_room_account_data_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let event: Box = db
@@ -145,7 +120,7 @@ pub async fn get_room_account_data_route(
.map_err(|_| Error::bad_database("Invalid account data event in db."))?
.content;
- Ok(get_room_account_data::Response { account_data }.into())
+ Ok(get_room_account_data::Response { account_data })
}
#[derive(Deserialize)]
diff --git a/src/client_server/context.rs b/src/client_server/context.rs
index e1177661a80078073d52e320cf640d57c100797f..60a3b23bda8faba873727660e411d8cbfb367535 100644
--- a/src/client_server/context.rs
+++ b/src/client_server/context.rs
@@ -1,28 +1,21 @@
-use crate::{database::DatabaseGuard, ConduitResult, Error, Ruma};
+use crate::{database::DatabaseGuard, Error, Result, Ruma};
use ruma::{
api::client::{error::ErrorKind, r0::context::get_context},
events::EventType,
};
use std::{collections::HashSet, convert::TryFrom};
-#[cfg(feature = "conduit_bin")]
-use rocket::get;
-
/// # `GET /_matrix/client/r0/rooms/{roomId}/context`
///
/// Allows loading room history around an event.
///
/// - Only works if the user is joined (TODO: always allow, but only show events if the user was
/// joined, depending on history_visibility)
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/rooms/<_>/context/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_context_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
@@ -149,5 +142,5 @@ pub async fn get_context_route(
state,
};
- Ok(resp.into())
+ Ok(resp)
}
diff --git a/src/client_server/device.rs b/src/client_server/device.rs
index f240f2e757f54d6bbfe5fff2746a0def172ecb51..e35da978c7e37a4ca29bdd00166ab06cb06c0925 100644
--- a/src/client_server/device.rs
+++ b/src/client_server/device.rs
@@ -1,4 +1,4 @@
-use crate::{database::DatabaseGuard, utils, ConduitResult, Error, Ruma};
+use crate::{database::DatabaseGuard, utils, Error, Result, Ruma};
use ruma::api::client::{
error::ErrorKind,
r0::{
@@ -8,21 +8,15 @@ use ruma::api::client::{
};
use super::SESSION_ID_LENGTH;
-#[cfg(feature = "conduit_bin")]
-use rocket::{delete, get, post, put};
/// # `GET /_matrix/client/r0/devices`
///
/// Get metadata on all devices of the sender user.
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/devices", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_devices_route(
db: DatabaseGuard,
body: Ruma,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let devices: Vec = db
@@ -31,21 +25,17 @@ pub async fn get_devices_route(
.filter_map(|r| r.ok()) // Filter out buggy devices
.collect();
- Ok(get_devices::Response { devices }.into())
+ Ok(get_devices::Response { devices })
}
/// # `GET /_matrix/client/r0/devices/{deviceId}`
///
/// Get metadata on a single device of the sender user.
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/devices/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_device_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let device = db
@@ -53,21 +43,17 @@ pub async fn get_device_route(
.get_device_metadata(sender_user, &body.body.device_id)?
.ok_or(Error::BadRequest(ErrorKind::NotFound, "Device not found."))?;
- Ok(get_device::Response { device }.into())
+ Ok(get_device::Response { device })
}
/// # `PUT /_matrix/client/r0/devices/{deviceId}`
///
/// Updates the metadata on a given device of the sender user.
-#[cfg_attr(
- feature = "conduit_bin",
- put("/_matrix/client/r0/devices/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn update_device_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let mut device = db
@@ -82,7 +68,7 @@ pub async fn update_device_route(
db.flush()?;
- Ok(update_device::Response {}.into())
+ Ok(update_device::Response {})
}
/// # `DELETE /_matrix/client/r0/devices/{deviceId}`
@@ -94,15 +80,11 @@ pub async fn update_device_route(
/// - Deletes device metadata (device id, device display name, last seen ip, last seen ts)
/// - Forgets to-device events
/// - Triggers device list updates
-#[cfg_attr(
- feature = "conduit_bin",
- delete("/_matrix/client/r0/devices/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn delete_device_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
@@ -143,7 +125,7 @@ pub async fn delete_device_route(
db.flush()?;
- Ok(delete_device::Response {}.into())
+ Ok(delete_device::Response {})
}
/// # `PUT /_matrix/client/r0/devices/{deviceId}`
@@ -157,15 +139,11 @@ pub async fn delete_device_route(
/// - Deletes device metadata (device id, device display name, last seen ip, last seen ts)
/// - Forgets to-device events
/// - Triggers device list updates
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/r0/delete_devices", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn delete_devices_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
@@ -208,5 +186,5 @@ pub async fn delete_devices_route(
db.flush()?;
- Ok(delete_devices::Response {}.into())
+ Ok(delete_devices::Response {})
}
diff --git a/src/client_server/directory.rs b/src/client_server/directory.rs
index 5a1bc4948fa0cb3f401188e2977d9037426906a1..9ae8bf3c409cfee18a37abe6dc0be0b5a0bc5eb9 100644
--- a/src/client_server/directory.rs
+++ b/src/client_server/directory.rs
@@ -1,6 +1,6 @@
use std::convert::TryInto;
-use crate::{database::DatabaseGuard, ConduitResult, Database, Error, Result, Ruma};
+use crate::{database::DatabaseGuard, Database, Error, Result, Ruma};
use ruma::{
api::{
client::{
@@ -31,23 +31,16 @@ use ruma::{
};
use tracing::{info, warn};
-#[cfg(feature = "conduit_bin")]
-use rocket::{get, post, put};
-
/// # `POST /_matrix/client/r0/publicRooms`
///
/// Lists the public rooms on this server.
///
/// - Rooms are ordered by the number of joined members
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/r0/publicRooms", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_public_rooms_filtered_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
get_public_rooms_filtered_helper(
&db,
body.server.as_deref(),
@@ -64,15 +57,11 @@ pub async fn get_public_rooms_filtered_route(
/// Lists the public rooms on this server.
///
/// - Rooms are ordered by the number of joined members
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/publicRooms", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_public_rooms_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let response = get_public_rooms_filtered_helper(
&db,
body.server.as_deref(),
@@ -81,16 +70,14 @@ pub async fn get_public_rooms_route(
&IncomingFilter::default(),
&IncomingRoomNetwork::Matrix,
)
- .await?
- .0;
+ .await?;
Ok(get_public_rooms::Response {
chunk: response.chunk,
prev_batch: response.prev_batch,
next_batch: response.next_batch,
total_room_count_estimate: response.total_room_count_estimate,
- }
- .into())
+ })
}
/// # `PUT /_matrix/client/r0/directory/list/room/{roomId}`
@@ -98,15 +85,11 @@ pub async fn get_public_rooms_route(
/// Sets the visibility of a given room in the room directory.
///
/// - TODO: Access control checks
-#[cfg_attr(
- feature = "conduit_bin",
- put("/_matrix/client/r0/directory/list/room/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn set_room_visibility_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
match &body.visibility {
@@ -125,29 +108,24 @@ pub async fn set_room_visibility_route(
db.flush()?;
- Ok(set_room_visibility::Response {}.into())
+ Ok(set_room_visibility::Response {})
}
/// # `GET /_matrix/client/r0/directory/list/room/{roomId}`
///
/// Gets the visibility of a given room in the room directory.
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/directory/list/room/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_room_visibility_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
Ok(get_room_visibility::Response {
visibility: if db.rooms.is_public_room(&body.room_id)? {
room::Visibility::Public
} else {
room::Visibility::Private
},
- }
- .into())
+ })
}
pub(crate) async fn get_public_rooms_filtered_helper(
@@ -157,7 +135,7 @@ pub(crate) async fn get_public_rooms_filtered_helper(
since: Option<&str>,
filter: &IncomingFilter,
_network: &IncomingRoomNetwork,
-) -> ConduitResult {
+) -> Result {
if let Some(other_server) = server.filter(|server| *server != db.globals.server_name().as_str())
{
let response = db
@@ -193,8 +171,7 @@ pub(crate) async fn get_public_rooms_filtered_helper(
prev_batch: response.prev_batch,
next_batch: response.next_batch,
total_room_count_estimate: response.total_room_count_estimate,
- }
- .into());
+ });
}
let limit = limit.map_or(10, u64::from);
@@ -374,6 +351,5 @@ pub(crate) async fn get_public_rooms_filtered_helper(
prev_batch,
next_batch,
total_room_count_estimate: Some(total_room_count_estimate),
- }
- .into())
+ })
}
diff --git a/src/client_server/filter.rs b/src/client_server/filter.rs
index f8845f1e95d1922423f941fee6fb1cd5da637123..28610ec08e2c0feba8e819369b8b1ac559338a9a 100644
--- a/src/client_server/filter.rs
+++ b/src/client_server/filter.rs
@@ -1,47 +1,38 @@
-use crate::{database::DatabaseGuard, ConduitResult, Error, Ruma};
+use crate::{database::DatabaseGuard, Error, Result, Ruma};
use ruma::api::client::{
error::ErrorKind,
r0::filter::{create_filter, get_filter},
};
-#[cfg(feature = "conduit_bin")]
-use rocket::{get, post};
-
/// # `GET /_matrix/client/r0/user/{userId}/filter/{filterId}`
///
/// Loads a filter that was previously created.
///
/// - A user can only access their own filters
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/user/<_>/filter/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_filter_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let filter = match db.users.get_filter(sender_user, &body.filter_id)? {
Some(filter) => filter,
None => return Err(Error::BadRequest(ErrorKind::NotFound, "Filter not found.")),
};
- Ok(get_filter::Response::new(filter).into())
+ Ok(get_filter::Response::new(filter))
}
/// # `PUT /_matrix/client/r0/user/{userId}/filter`
///
/// Creates a new filter to be used by other endpoints.
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/r0/user/<_>/filter", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn create_filter_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
- Ok(create_filter::Response::new(db.users.create_filter(sender_user, &body.filter)?).into())
+ Ok(create_filter::Response::new(
+ db.users.create_filter(sender_user, &body.filter)?,
+ ))
}
diff --git a/src/client_server/keys.rs b/src/client_server/keys.rs
index e7aec26b473ce353d9050a7c828dc993d164b20d..d272ff410ecedb0e6dd3f031c61709a1ee56a7a9 100644
--- a/src/client_server/keys.rs
+++ b/src/client_server/keys.rs
@@ -1,6 +1,6 @@
use super::SESSION_ID_LENGTH;
-use crate::{database::DatabaseGuard, utils, ConduitResult, Database, Error, Result, Ruma};
-use rocket::futures::{prelude::*, stream::FuturesUnordered};
+use crate::{database::DatabaseGuard, utils, Database, Error, Result, Ruma};
+use futures_util::{stream::FuturesUnordered, StreamExt};
use ruma::{
api::{
client::{
@@ -21,24 +21,17 @@ use ruma::{
use serde_json::json;
use std::collections::{BTreeMap, HashMap, HashSet};
-#[cfg(feature = "conduit_bin")]
-use rocket::{get, post};
-
/// # `POST /_matrix/client/r0/keys/upload`
///
/// Publish end-to-end encryption keys for the sender device.
///
/// - Adds one time keys
/// - If there are no device keys yet: Adds device keys (TODO: merge with existing keys?)
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/r0/keys/upload", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn upload_keys_route(
db: DatabaseGuard,
body: Ruma,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
@@ -69,8 +62,7 @@ pub async fn upload_keys_route(
Ok(upload_keys::Response {
one_time_key_counts: db.users.count_one_time_keys(sender_user, sender_device)?,
- }
- .into())
+ })
}
/// # `POST /_matrix/client/r0/keys/query`
@@ -80,15 +72,11 @@ pub async fn upload_keys_route(
/// - Always fetches users from other servers over federation
/// - Gets master keys, self-signing keys, user signing keys and device keys.
/// - The master and self-signing keys contain signatures that the user is allowed to see
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/r0/keys/query", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_keys_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let response = get_keys_helper(
@@ -99,26 +87,22 @@ pub async fn get_keys_route(
)
.await?;
- Ok(response.into())
+ Ok(response)
}
/// # `POST /_matrix/client/r0/keys/claim`
///
/// Claims one-time keys
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/r0/keys/claim", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn claim_keys_route(
db: DatabaseGuard,
body: Ruma,
-) -> ConduitResult {
+) -> Result {
let response = claim_keys_helper(&body.one_time_keys, &db).await?;
db.flush()?;
- Ok(response.into())
+ Ok(response)
}
/// # `POST /_matrix/client/r0/keys/device_signing/upload`
@@ -126,15 +110,11 @@ pub async fn claim_keys_route(
/// Uploads end-to-end key information for the sender user.
///
/// - Requires UIAA to verify password
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/unstable/keys/device_signing/upload", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn upload_signing_keys_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
@@ -184,21 +164,17 @@ pub async fn upload_signing_keys_route(
db.flush()?;
- Ok(upload_signing_keys::Response {}.into())
+ Ok(upload_signing_keys::Response {})
}
/// # `POST /_matrix/client/r0/keys/signatures/upload`
///
/// Uploads end-to-end key signatures from the sender user.
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/unstable/keys/signatures/upload", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn upload_signatures_route(
db: DatabaseGuard,
body: Ruma,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
for (user_id, signed_keys) in &body.signed_keys {
@@ -248,7 +224,7 @@ pub async fn upload_signatures_route(
db.flush()?;
- Ok(upload_signatures::Response {}.into())
+ Ok(upload_signatures::Response {})
}
/// # `POST /_matrix/client/r0/keys/changes`
@@ -256,15 +232,11 @@ pub async fn upload_signatures_route(
/// Gets a list of users who have updated their device identity keys since the previous sync token.
///
/// - TODO: left users
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/keys/changes", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_key_changes_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let mut device_list_updates = HashSet::new();
@@ -303,8 +275,7 @@ pub async fn get_key_changes_route(
Ok(get_key_changes::Response {
changed: device_list_updates.into_iter().collect(),
left: Vec::new(), // TODO
- }
- .into())
+ })
}
pub(crate) async fn get_keys_helper bool>(
diff --git a/src/client_server/media.rs b/src/client_server/media.rs
index 0a7f4bb5e290721058f7aab5cdee95f72a2600e4..01f5d6cef17e44ca0f32ea60a582dadb36521466 100644
--- a/src/client_server/media.rs
+++ b/src/client_server/media.rs
@@ -1,6 +1,6 @@
use crate::{
database::{media::FileMeta, DatabaseGuard},
- utils, ConduitResult, Error, Ruma,
+ utils, Error, Result, Ruma,
};
use ruma::api::client::{
error::ErrorKind,
@@ -8,23 +8,19 @@ use ruma::api::client::{
};
use std::convert::TryInto;
-#[cfg(feature = "conduit_bin")]
-use rocket::{get, post};
-
const MXC_LENGTH: usize = 32;
/// # `GET /_matrix/media/r0/config`
///
/// Returns max upload size.
-#[cfg_attr(feature = "conduit_bin", get("/_matrix/media/r0/config"))]
-#[tracing::instrument(skip(db))]
+#[tracing::instrument(skip(db, _body))]
pub async fn get_media_config_route(
db: DatabaseGuard,
-) -> ConduitResult {
+ _body: Ruma,
+) -> Result {
Ok(get_media_config::Response {
upload_size: db.globals.max_request_size().into(),
- }
- .into())
+ })
}
/// # `POST /_matrix/media/r0/upload`
@@ -33,15 +29,11 @@ pub async fn get_media_config_route(
///
/// - Some metadata will be saved in the database
/// - Media will be saved in the media/ directory
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/media/r0/upload", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn create_content_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let mxc = format!(
"mxc://{}/{}",
db.globals.server_name(),
@@ -67,8 +59,7 @@ pub async fn create_content_route(
Ok(create_content::Response {
content_uri: mxc.try_into().expect("Invalid mxc:// URI"),
blurhash: None,
- }
- .into())
+ })
}
/// # `POST /_matrix/media/r0/download/{serverName}/{mediaId}`
@@ -76,15 +67,11 @@ pub async fn create_content_route(
/// Load media from our server or over federation.
///
/// - Only allows federation if `allow_remote` is true
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/media/r0/download/<_>/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_content_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
if let Some(FileMeta {
@@ -97,8 +84,7 @@ pub async fn get_content_route(
file,
content_type,
content_disposition,
- }
- .into())
+ })
} else if &*body.server_name != db.globals.server_name() && body.allow_remote {
let get_content_response = db
.sending
@@ -123,7 +109,7 @@ pub async fn get_content_route(
)
.await?;
- Ok(get_content_response.into())
+ Ok(get_content_response)
} else {
Err(Error::BadRequest(ErrorKind::NotFound, "Media not found."))
}
@@ -134,15 +120,11 @@ pub async fn get_content_route(
/// Load media thumbnail from our server or over federation.
///
/// - Only allows federation if `allow_remote` is true
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/media/r0/thumbnail/<_>/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_content_thumbnail_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
if let Some(FileMeta {
@@ -161,7 +143,7 @@ pub async fn get_content_thumbnail_route(
)
.await?
{
- Ok(get_content_thumbnail::Response { file, content_type }.into())
+ Ok(get_content_thumbnail::Response { file, content_type })
} else if &*body.server_name != db.globals.server_name() && body.allow_remote {
let get_thumbnail_response = db
.sending
@@ -191,7 +173,7 @@ pub async fn get_content_thumbnail_route(
)
.await?;
- Ok(get_thumbnail_response.into())
+ Ok(get_thumbnail_response)
} else {
Err(Error::BadRequest(ErrorKind::NotFound, "Media not found."))
}
diff --git a/src/client_server/membership.rs b/src/client_server/membership.rs
index 70352784e415111b90860eef1482692891d28f04..4db0642e5f982bff1ee50c7eee56b14fbeef4092 100644
--- a/src/client_server/membership.rs
+++ b/src/client_server/membership.rs
@@ -2,7 +2,7 @@ use crate::{
client_server,
database::DatabaseGuard,
pdu::{EventHash, PduBuilder, PduEvent},
- server_server, utils, ConduitResult, Database, Error, Result, Ruma,
+ server_server, utils, Database, Error, Result, Ruma,
};
use ruma::{
api::{
@@ -37,24 +37,17 @@ use std::{
};
use tracing::{debug, error, warn};
-#[cfg(feature = "conduit_bin")]
-use rocket::{get, post};
-
/// # `POST /_matrix/client/r0/rooms/{roomId}/join`
///
/// Tries to join the sender user into a room.
///
/// - If the server knowns about this room: creates the join event and does auth rules locally
/// - If the server does not know about the room: asks other servers over federation
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/r0/rooms/<_>/join", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn join_room_by_id_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let mut servers: HashSet<_> = db
@@ -91,15 +84,11 @@ pub async fn join_room_by_id_route(
///
/// - If the server knowns about this room: creates the join event and does auth rules locally
/// - If the server does not know about the room: asks other servers over federation
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/r0/join/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn join_room_by_id_or_alias_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_deref().expect("user is authenticated");
let body = body.body;
@@ -123,7 +112,7 @@ pub async fn join_room_by_id_or_alias_route(
Err(room_alias) => {
let response = client_server::get_alias_helper(&db, &room_alias).await?;
- (response.0.servers.into_iter().collect(), response.0.room_id)
+ (response.servers.into_iter().collect(), response.room_id)
}
};
@@ -139,9 +128,8 @@ pub async fn join_room_by_id_or_alias_route(
db.flush()?;
Ok(join_room_by_id_or_alias::Response {
- room_id: join_room_response.0.room_id,
- }
- .into())
+ room_id: join_room_response.room_id,
+ })
}
/// # `POST /_matrix/client/r0/rooms/{roomId}/leave`
@@ -149,42 +137,34 @@ pub async fn join_room_by_id_or_alias_route(
/// Tries to leave the sender user from a room.
///
/// - This should always work if the user is currently joined.
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/r0/rooms/<_>/leave", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn leave_room_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
db.rooms.leave_room(sender_user, &body.room_id, &db).await?;
db.flush()?;
- Ok(leave_room::Response::new().into())
+ Ok(leave_room::Response::new())
}
/// # `POST /_matrix/client/r0/rooms/{roomId}/invite`
///
/// Tries to send an invite event into the room.
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/r0/rooms/<_>/invite", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn invite_user_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if let invite_user::IncomingInvitationRecipient::UserId { user_id } = &body.recipient {
invite_helper(sender_user, user_id, &body.room_id, &db, false).await?;
db.flush()?;
- Ok(invite_user::Response {}.into())
+ Ok(invite_user::Response {})
} else {
Err(Error::BadRequest(ErrorKind::NotFound, "User not found."))
}
@@ -193,15 +173,11 @@ pub async fn invite_user_route(
/// # `POST /_matrix/client/r0/rooms/{roomId}/kick`
///
/// Tries to send a kick event into the room.
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/r0/rooms/<_>/kick", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn kick_user_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let mut event: RoomMemberEventContent = serde_json::from_str(
@@ -251,21 +227,17 @@ pub async fn kick_user_route(
db.flush()?;
- Ok(kick_user::Response::new().into())
+ Ok(kick_user::Response::new())
}
/// # `POST /_matrix/client/r0/rooms/{roomId}/ban`
///
/// Tries to send a ban event into the room.
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/r0/rooms/<_>/ban", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn ban_user_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
// TODO: reason
@@ -326,21 +298,17 @@ pub async fn ban_user_route(
db.flush()?;
- Ok(ban_user::Response::new().into())
+ Ok(ban_user::Response::new())
}
/// # `POST /_matrix/client/r0/rooms/{roomId}/unban`
///
/// Tries to send an unban event into the room.
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/r0/rooms/<_>/unban", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn unban_user_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let mut event: RoomMemberEventContent = serde_json::from_str(
@@ -389,7 +357,7 @@ pub async fn unban_user_route(
db.flush()?;
- Ok(unban_user::Response::new().into())
+ Ok(unban_user::Response::new())
}
/// # `POST /_matrix/client/r0/rooms/{roomId}/forget`
@@ -400,36 +368,28 @@ pub async fn unban_user_route(
///
/// Note: Other devices of the user have no way of knowing the room was forgotten, so this has to
/// be called from every device
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/r0/rooms/<_>/forget", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn forget_room_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
db.rooms.forget(&body.room_id, sender_user)?;
db.flush()?;
- Ok(forget_room::Response::new().into())
+ Ok(forget_room::Response::new())
}
/// # `POST /_matrix/client/r0/joined_rooms`
///
/// Lists all rooms the user has joined.
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/joined_rooms", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn joined_rooms_route(
db: DatabaseGuard,
body: Ruma,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
Ok(joined_rooms::Response {
@@ -438,8 +398,7 @@ pub async fn joined_rooms_route(
.rooms_joined(sender_user)
.filter_map(|r| r.ok())
.collect(),
- }
- .into())
+ })
}
/// # `POST /_matrix/client/r0/rooms/{roomId}/members`
@@ -447,15 +406,11 @@ pub async fn joined_rooms_route(
/// Lists all joined users in a room (TODO: at a specific point in time, with a specific membership).
///
/// - Only works if the user is currently joined
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/rooms/<_>/members", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_member_events_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
// TODO: check history visibility?
@@ -474,8 +429,7 @@ pub async fn get_member_events_route(
.filter(|(key, _)| key.0 == EventType::RoomMember)
.map(|(_, pdu)| pdu.to_member_event())
.collect(),
- }
- .into())
+ })
}
/// # `POST /_matrix/client/r0/rooms/{roomId}/joined_members`
@@ -484,15 +438,11 @@ pub async fn get_member_events_route(
///
/// - The sender user must be in the room
/// - TODO: An appservice just needs a puppet joined
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/rooms/<_>/joined_members", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn joined_members_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if !db.rooms.is_joined(sender_user, &body.room_id)? {
@@ -516,7 +466,7 @@ pub async fn joined_members_route(
);
}
- Ok(joined_members::Response { joined }.into())
+ Ok(joined_members::Response { joined })
}
#[tracing::instrument(skip(db))]
@@ -526,7 +476,7 @@ async fn join_room_by_id_helper(
room_id: &RoomId,
servers: &HashSet>,
_third_party_signed: Option<&IncomingThirdPartySigned>,
-) -> ConduitResult {
+) -> Result {
let sender_user = sender_user.expect("user is authenticated");
let mutex_state = Arc::clone(
@@ -781,7 +731,7 @@ async fn join_room_by_id_helper(
db.flush()?;
- Ok(join_room_by_id::Response::new(room_id.to_owned()).into())
+ Ok(join_room_by_id::Response::new(room_id.to_owned()))
}
fn validate_and_add_event_id(
diff --git a/src/client_server/message.rs b/src/client_server/message.rs
index 7d904f900e8042c635a17fca90515ca29dd961b1..72363e4bbadfdd151b44c7c99def47d1305493f1 100644
--- a/src/client_server/message.rs
+++ b/src/client_server/message.rs
@@ -1,4 +1,4 @@
-use crate::{database::DatabaseGuard, pdu::PduBuilder, utils, ConduitResult, Error, Ruma};
+use crate::{database::DatabaseGuard, pdu::PduBuilder, utils, Error, Result, Ruma};
use ruma::{
api::client::{
error::ErrorKind,
@@ -12,9 +12,6 @@ use std::{
sync::Arc,
};
-#[cfg(feature = "conduit_bin")]
-use rocket::{get, put};
-
/// # `PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}`
///
/// Send a message event into the room.
@@ -22,15 +19,11 @@ use rocket::{get, put};
/// - Is a NOOP if the txn id was already used before and returns the same event id again
/// - The only requirement for the content is that it has to be valid json
/// - Tries to send the event into the room, auth rules will determine if it is allowed
-#[cfg_attr(
- feature = "conduit_bin",
- put("/_matrix/client/r0/rooms/<_>/send/<_>/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn send_message_event_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let sender_device = body.sender_device.as_deref();
@@ -70,7 +63,7 @@ pub async fn send_message_event_route(
.map_err(|_| Error::bad_database("Invalid txnid bytes in database."))?
.try_into()
.map_err(|_| Error::bad_database("Invalid event id in txnid data."))?;
- return Ok(send_message_event::Response { event_id }.into());
+ return Ok(send_message_event::Response { event_id });
}
let mut unsigned = BTreeMap::new();
@@ -102,7 +95,7 @@ pub async fn send_message_event_route(
db.flush()?;
- Ok(send_message_event::Response::new((*event_id).to_owned()).into())
+ Ok(send_message_event::Response::new((*event_id).to_owned()))
}
/// # `GET /_matrix/client/r0/rooms/{roomId}/messages`
@@ -111,15 +104,11 @@ pub async fn send_message_event_route(
///
/// - Only works if the user is joined (TODO: always allow, but only show events where the user was
/// joined, depending on history_visibility)
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/rooms/<_>/messages", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_message_events_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
@@ -247,5 +236,5 @@ pub async fn get_message_events_route(
);
}
- Ok(resp.into())
+ Ok(resp)
}
diff --git a/src/client_server/mod.rs b/src/client_server/mod.rs
index 115ddaf608308f4b2789ff5a12e9e72738b99ed1..a7241b0d763dc36889705b4307e2a8b438369ff9 100644
--- a/src/client_server/mod.rs
+++ b/src/client_server/mod.rs
@@ -62,23 +62,6 @@ pub use unversioned::*;
pub use user_directory::*;
pub use voip::*;
-#[cfg(not(feature = "conduit_bin"))]
-use super::State;
-#[cfg(feature = "conduit_bin")]
-use {
- crate::ConduitResult, rocket::options, ruma::api::client::r0::to_device::send_event_to_device,
-};
-
pub const DEVICE_ID_LENGTH: usize = 10;
pub const TOKEN_LENGTH: usize = 256;
pub const SESSION_ID_LENGTH: usize = 256;
-
-/// # `OPTIONS`
-///
-/// Web clients use this to get CORS headers.
-#[cfg(feature = "conduit_bin")]
-#[options("/<_..>")]
-#[tracing::instrument]
-pub async fn options_route() -> ConduitResult {
- Ok(send_event_to_device::Response {}.into())
-}
diff --git a/src/client_server/presence.rs b/src/client_server/presence.rs
index aaa78a9287b9b805372eb9962b266e6bb002c9db..8e58968cfddd476c12a2dab17176c9ac0315e9c0 100644
--- a/src/client_server/presence.rs
+++ b/src/client_server/presence.rs
@@ -1,22 +1,15 @@
-use crate::{database::DatabaseGuard, utils, ConduitResult, Ruma};
+use crate::{database::DatabaseGuard, utils, Result, Ruma};
use ruma::api::client::r0::presence::{get_presence, set_presence};
use std::{convert::TryInto, time::Duration};
-#[cfg(feature = "conduit_bin")]
-use rocket::{get, put};
-
/// # `PUT /_matrix/client/r0/presence/{userId}/status`
///
/// Sets the presence state of the sender user.
-#[cfg_attr(
- feature = "conduit_bin",
- put("/_matrix/client/r0/presence/<_>/status", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn set_presence_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
for room_id in db.rooms.rooms_joined(sender_user) {
@@ -46,7 +39,7 @@ pub async fn set_presence_route(
db.flush()?;
- Ok(set_presence::Response {}.into())
+ Ok(set_presence::Response {})
}
/// # `GET /_matrix/client/r0/presence/{userId}/status`
@@ -54,15 +47,11 @@ pub async fn set_presence_route(
/// Gets the presence state of the given user.
///
/// - Only works if you share a room with the user
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/presence/<_>/status", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_presence_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let mut presence_event = None;
@@ -93,8 +82,7 @@ pub async fn get_presence_route(
.last_active_ago
.map(|millis| Duration::from_millis(millis.into())),
presence: presence.content.presence,
- }
- .into())
+ })
} else {
todo!();
}
diff --git a/src/client_server/profile.rs b/src/client_server/profile.rs
index 71e61da32388113196fe700441d17f41b79a560a..9c3f6347e8b28a14696ed74fc3769543dd170c06 100644
--- a/src/client_server/profile.rs
+++ b/src/client_server/profile.rs
@@ -1,4 +1,4 @@
-use crate::{database::DatabaseGuard, pdu::PduBuilder, utils, ConduitResult, Error, Ruma};
+use crate::{database::DatabaseGuard, pdu::PduBuilder, utils, Error, Result, Ruma};
use ruma::{
api::{
client::{
@@ -14,23 +14,16 @@ use ruma::{
use serde_json::value::to_raw_value;
use std::{convert::TryInto, sync::Arc};
-#[cfg(feature = "conduit_bin")]
-use rocket::{get, put};
-
/// # `PUT /_matrix/client/r0/profile/{userId}/displayname`
///
/// Updates the displayname.
///
/// - Also makes sure other users receive the update using presence EDUs
-#[cfg_attr(
- feature = "conduit_bin",
- put("/_matrix/client/r0/profile/<_>/displayname", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn set_displayname_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
db.users
@@ -116,7 +109,7 @@ pub async fn set_displayname_route(
db.flush()?;
- Ok(set_display_name::Response {}.into())
+ Ok(set_display_name::Response {})
}
/// # `GET /_matrix/client/r0/profile/{userId}/displayname`
@@ -124,15 +117,11 @@ pub async fn set_displayname_route(
/// Returns the displayname of the user.
///
/// - If user is on another server: Fetches displayname over federation
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/profile/<_>/displayname", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_displayname_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
if body.user_id.server_name() != db.globals.server_name() {
let response = db
.sending
@@ -148,14 +137,12 @@ pub async fn get_displayname_route(
return Ok(get_display_name::Response {
displayname: response.displayname,
- }
- .into());
+ });
}
Ok(get_display_name::Response {
displayname: db.users.displayname(&body.user_id)?,
- }
- .into())
+ })
}
/// # `PUT /_matrix/client/r0/profile/{userId}/avatar_url`
@@ -163,15 +150,11 @@ pub async fn get_displayname_route(
/// Updates the avatar_url and blurhash.
///
/// - Also makes sure other users receive the update using presence EDUs
-#[cfg_attr(
- feature = "conduit_bin",
- put("/_matrix/client/r0/profile/<_>/avatar_url", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn set_avatar_url_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
db.users
@@ -259,7 +242,7 @@ pub async fn set_avatar_url_route(
db.flush()?;
- Ok(set_avatar_url::Response {}.into())
+ Ok(set_avatar_url::Response {})
}
/// # `GET /_matrix/client/r0/profile/{userId}/avatar_url`
@@ -267,15 +250,11 @@ pub async fn set_avatar_url_route(
/// Returns the avatar_url and blurhash of the user.
///
/// - If user is on another server: Fetches avatar_url and blurhash over federation
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/profile/<_>/avatar_url", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_avatar_url_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
if body.user_id.server_name() != db.globals.server_name() {
let response = db
.sending
@@ -292,15 +271,13 @@ pub async fn get_avatar_url_route(
return Ok(get_avatar_url::Response {
avatar_url: response.avatar_url,
blurhash: response.blurhash,
- }
- .into());
+ });
}
Ok(get_avatar_url::Response {
avatar_url: db.users.avatar_url(&body.user_id)?,
blurhash: db.users.blurhash(&body.user_id)?,
- }
- .into())
+ })
}
/// # `GET /_matrix/client/r0/profile/{userId}`
@@ -308,15 +285,11 @@ pub async fn get_avatar_url_route(
/// Returns the displayname, avatar_url and blurhash of the user.
///
/// - If user is on another server: Fetches profile over federation
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/profile/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_profile_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
if body.user_id.server_name() != db.globals.server_name() {
let response = db
.sending
@@ -334,8 +307,7 @@ pub async fn get_profile_route(
displayname: response.displayname,
avatar_url: response.avatar_url,
blurhash: response.blurhash,
- }
- .into());
+ });
}
if !db.users.exists(&body.user_id)? {
@@ -350,6 +322,5 @@ pub async fn get_profile_route(
avatar_url: db.users.avatar_url(&body.user_id)?,
blurhash: db.users.blurhash(&body.user_id)?,
displayname: db.users.displayname(&body.user_id)?,
- }
- .into())
+ })
}
diff --git a/src/client_server/push.rs b/src/client_server/push.rs
index a8ba1a2a43c30fdf0a1aa52994bb9dbcad8ec74a..3bc46b85472fa7cad4683b1a440f621b03ce7bfc 100644
--- a/src/client_server/push.rs
+++ b/src/client_server/push.rs
@@ -1,4 +1,4 @@
-use crate::{database::DatabaseGuard, ConduitResult, Error, Ruma};
+use crate::{database::DatabaseGuard, Error, Result, Ruma};
use ruma::{
api::client::{
error::ErrorKind,
@@ -12,21 +12,14 @@ use ruma::{
push::{ConditionalPushRuleInit, PatternedPushRuleInit, SimplePushRuleInit},
};
-#[cfg(feature = "conduit_bin")]
-use rocket::{delete, get, post, put};
-
/// # `GET /_matrix/client/r0/pushrules`
///
/// Retrieves the push rules event for this user.
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/pushrules", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_pushrules_all_route(
db: DatabaseGuard,
body: Ruma,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let event: PushRulesEvent = db
@@ -39,22 +32,17 @@ pub async fn get_pushrules_all_route(
Ok(get_pushrules_all::Response {
global: event.content.global,
- }
- .into())
+ })
}
/// # `GET /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}`
///
/// Retrieves a single specified push rule for this user.
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/pushrules/<_>/<_>/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_pushrule_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let event: PushRulesEvent = db
@@ -91,7 +79,7 @@ pub async fn get_pushrule_route(
};
if let Some(rule) = rule {
- Ok(get_pushrule::Response { rule }.into())
+ Ok(get_pushrule::Response { rule })
} else {
Err(Error::BadRequest(
ErrorKind::NotFound,
@@ -103,15 +91,11 @@ pub async fn get_pushrule_route(
/// # `PUT /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}`
///
/// Creates a single specified push rule for this user.
-#[cfg_attr(
- feature = "conduit_bin",
- put("/_matrix/client/r0/pushrules/<_>/<_>/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn set_pushrule_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let body = body.body;
@@ -198,21 +182,17 @@ pub async fn set_pushrule_route(
db.flush()?;
- Ok(set_pushrule::Response {}.into())
+ Ok(set_pushrule::Response {})
}
/// # `GET /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/actions`
///
/// Gets the actions of a single specified push rule for this user.
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/pushrules/<_>/<_>/<_>/actions", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_pushrule_actions_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if body.scope != "global" {
@@ -259,22 +239,17 @@ pub async fn get_pushrule_actions_route(
Ok(get_pushrule_actions::Response {
actions: actions.unwrap_or_default(),
- }
- .into())
+ })
}
/// # `PUT /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/actions`
///
/// Sets the actions of a single specified push rule for this user.
-#[cfg_attr(
- feature = "conduit_bin",
- put("/_matrix/client/r0/pushrules/<_>/<_>/<_>/actions", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn set_pushrule_actions_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if body.scope != "global" {
@@ -332,21 +307,17 @@ pub async fn set_pushrule_actions_route(
db.flush()?;
- Ok(set_pushrule_actions::Response {}.into())
+ Ok(set_pushrule_actions::Response {})
}
/// # `GET /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/enabled`
///
/// Gets the enabled status of a single specified push rule for this user.
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/pushrules/<_>/<_>/<_>/enabled", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_pushrule_enabled_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if body.scope != "global" {
@@ -396,21 +367,17 @@ pub async fn get_pushrule_enabled_route(
db.flush()?;
- Ok(get_pushrule_enabled::Response { enabled }.into())
+ Ok(get_pushrule_enabled::Response { enabled })
}
/// # `PUT /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}/enabled`
///
/// Sets the enabled status of a single specified push rule for this user.
-#[cfg_attr(
- feature = "conduit_bin",
- put("/_matrix/client/r0/pushrules/<_>/<_>/<_>/enabled", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn set_pushrule_enabled_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if body.scope != "global" {
@@ -473,21 +440,17 @@ pub async fn set_pushrule_enabled_route(
db.flush()?;
- Ok(set_pushrule_enabled::Response {}.into())
+ Ok(set_pushrule_enabled::Response {})
}
/// # `DELETE /_matrix/client/r0/pushrules/{scope}/{kind}/{ruleId}`
///
/// Deletes a single specified push rule for this user.
-#[cfg_attr(
- feature = "conduit_bin",
- delete("/_matrix/client/r0/pushrules/<_>/<_>/<_>", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn delete_pushrule_route(
db: DatabaseGuard,
body: Ruma>,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if body.scope != "global" {
@@ -540,27 +503,22 @@ pub async fn delete_pushrule_route(
db.flush()?;
- Ok(delete_pushrule::Response {}.into())
+ Ok(delete_pushrule::Response {})
}
/// # `GET /_matrix/client/r0/pushers`
///
/// Gets all currently active pushers for the sender user.
-#[cfg_attr(
- feature = "conduit_bin",
- get("/_matrix/client/r0/pushers", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn get_pushers_route(
db: DatabaseGuard,
body: Ruma,
-) -> ConduitResult {
+) -> Result {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
Ok(get_pushers::Response {
pushers: db.pusher.get_pushers(sender_user)?,
- }
- .into())
+ })
}
/// # `POST /_matrix/client/r0/pushers/set`
@@ -568,15 +526,11 @@ pub async fn get_pushers_route(
/// Adds a pusher for the sender user.
///
/// - TODO: Handle `append`
-#[cfg_attr(
- feature = "conduit_bin",
- post("/_matrix/client/r0/pushers/set", data = "")
-)]
#[tracing::instrument(skip(db, body))]
pub async fn set_pushers_route(
db: DatabaseGuard,
body: Ruma,
-) -> ConduitResult