Browse Source

Add 'm.login.token' authentication

merge-requests/22/head
Andrei Orlov 5 years ago committed by Timo Kösters
parent
commit
eecbc5cfcc
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4
  1. 64
      Cargo.lock
  2. 2
      Cargo.toml
  3. 8
      src/client_server/account.rs
  4. 8
      src/client_server/alias.rs
  5. 28
      src/client_server/backup.rs
  6. 4
      src/client_server/config.rs
  7. 2
      src/client_server/context.rs
  8. 10
      src/client_server/device.rs
  9. 10
      src/client_server/directory.rs
  10. 12
      src/client_server/keys.rs
  11. 8
      src/client_server/media.rs
  12. 24
      src/client_server/membership.rs
  13. 4
      src/client_server/message.rs
  14. 2
      src/client_server/presence.rs
  15. 10
      src/client_server/profile.rs
  16. 8
      src/client_server/push.rs
  17. 2
      src/client_server/read_marker.rs
  18. 2
      src/client_server/redact.rs
  19. 6
      src/client_server/room.rs
  20. 2
      src/client_server/search.rs
  21. 66
      src/client_server/session.rs
  22. 12
      src/client_server/state.rs
  23. 4
      src/client_server/sync.rs
  24. 6
      src/client_server/tag.rs
  25. 2
      src/client_server/to_device.rs
  26. 2
      src/client_server/typing.rs
  27. 2
      src/client_server/user_directory.rs
  28. 6
      src/database.rs
  29. 2
      src/database/account_data.rs
  30. 2
      src/database/admin.rs
  31. 19
      src/database/globals.rs
  32. 6
      src/database/key_backups.rs
  33. 8
      src/database/rooms.rs
  34. 18
      src/database/rooms/edus.rs
  35. 4
      src/database/sending.rs
  36. 2
      src/database/uiaa.rs
  37. 14
      src/database/users.rs
  38. 2
      src/ruma_wrapper.rs
  39. 22
      src/server_server.rs

64
Cargo.lock generated

@ -21,6 +21,15 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234"
[[package]]
name = "aho-corasick"
version = "0.7.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b476ce7103678b0c6d3d395dbbae31d48ff910bd28be979ba5d48c6351131d0d"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "ansi_term" name = "ansi_term"
version = "0.12.1" version = "0.12.1"
@ -216,6 +225,7 @@ dependencies = [
"http", "http",
"image", "image",
"js_int", "js_int",
"jsonwebtoken",
"log", "log",
"rand", "rand",
"reqwest", "reqwest",
@ -844,6 +854,20 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "jsonwebtoken"
version = "7.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afabcc15e437a6484fc4f12d0fd63068fe457bf93f1c148d3d9649c60b103f32"
dependencies = [
"base64",
"pem",
"ring",
"serde",
"serde_json",
"simple_asn1",
]
[[package]] [[package]]
name = "kernel32-sys" name = "kernel32-sys"
version = "0.2.2" version = "0.2.2"
@ -1053,6 +1077,17 @@ dependencies = [
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "num-bigint"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]] [[package]]
name = "num-integer" name = "num-integer"
version = "0.1.43" version = "0.1.43"
@ -1206,6 +1241,17 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "pem"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59698ea79df9bf77104aefd39cc3ec990cb9693fb59c3b0a70ddf2646fdffb4b"
dependencies = [
"base64",
"once_cell",
"regex",
]
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.1.0" version = "2.1.0"
@ -1409,7 +1455,10 @@ version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8963b85b8ce3074fecffde43b4b0dded83ce2f367dc8d363afc56679f3ee820b" checksum = "8963b85b8ce3074fecffde43b4b0dded83ce2f367dc8d363afc56679f3ee820b"
dependencies = [ dependencies = [
"aho-corasick",
"memchr",
"regex-syntax", "regex-syntax",
"thread_local",
] ]
[[package]] [[package]]
@ -1918,6 +1967,17 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "simple_asn1"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "692ca13de57ce0613a363c8c2f1de925adebc81b04c923ac60c5488bb44abe4b"
dependencies = [
"chrono",
"num-bigint",
"num-traits",
]
[[package]] [[package]]
name = "slab" name = "slab"
version = "0.4.2" version = "0.4.2"
@ -2067,9 +2127,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.44" version = "1.0.45"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e03e57e4fcbfe7749842d53e24ccb9aa12b7252dbe5e91d2acad31834c8b8fdd" checksum = "ea9c5432ff16d6152371f808fb5a871cd67368171b09bb21b43df8e4a47a3556"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

2
Cargo.toml

@ -59,6 +59,8 @@ ring = "0.16.15"
# Used when querying the SRV record of other servers # Used when querying the SRV record of other servers
trust-dns-resolver = "0.19.5" trust-dns-resolver = "0.19.5"
jsonwebtoken = "7.2.0"
[features] [features]
default = ["conduit_bin"] default = ["conduit_bin"]
conduit_bin = [] # TODO: add rocket to this when it is optional conduit_bin = [] # TODO: add rocket to this when it is optional

8
src/client_server/account.rs

@ -43,7 +43,7 @@ const GUEST_NAME_LENGTH: usize = 10;
get("/_matrix/client/r0/register/available", data = "<body>") get("/_matrix/client/r0/register/available", data = "<body>")
)] )]
pub async fn get_register_available_route( pub async fn get_register_available_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_username_availability::Request<'_>>, body: Ruma<get_username_availability::Request<'_>>,
) -> ConduitResult<get_username_availability::Response> { ) -> ConduitResult<get_username_availability::Response> {
// Validate user id // Validate user id
@ -85,7 +85,7 @@ pub async fn get_register_available_route(
post("/_matrix/client/r0/register", data = "<body>") post("/_matrix/client/r0/register", data = "<body>")
)] )]
pub async fn register_route( pub async fn register_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<register::Request<'_>>, body: Ruma<register::Request<'_>>,
) -> ConduitResult<register::Response> { ) -> ConduitResult<register::Response> {
if db.globals.registration_disabled() { if db.globals.registration_disabled() {
@ -532,7 +532,7 @@ pub async fn register_route(
post("/_matrix/client/r0/account/password", data = "<body>") post("/_matrix/client/r0/account/password", data = "<body>")
)] )]
pub async fn change_password_route( pub async fn change_password_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<change_password::Request<'_>>, body: Ruma<change_password::Request<'_>>,
) -> ConduitResult<change_password::Response> { ) -> ConduitResult<change_password::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -616,7 +616,7 @@ pub async fn whoami_route(body: Ruma<whoami::Request>) -> ConduitResult<whoami::
post("/_matrix/client/r0/account/deactivate", data = "<body>") post("/_matrix/client/r0/account/deactivate", data = "<body>")
)] )]
pub async fn deactivate_route( pub async fn deactivate_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<deactivate::Request<'_>>, body: Ruma<deactivate::Request<'_>>,
) -> ConduitResult<deactivate::Response> { ) -> ConduitResult<deactivate::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");

8
src/client_server/alias.rs

@ -19,7 +19,7 @@ use rocket::{delete, get, put};
put("/_matrix/client/r0/directory/room/<_>", data = "<body>") put("/_matrix/client/r0/directory/room/<_>", data = "<body>")
)] )]
pub async fn create_alias_route( pub async fn create_alias_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<create_alias::Request<'_>>, body: Ruma<create_alias::Request<'_>>,
) -> ConduitResult<create_alias::Response> { ) -> ConduitResult<create_alias::Response> {
if db.rooms.id_from_alias(&body.room_alias)?.is_some() { if db.rooms.id_from_alias(&body.room_alias)?.is_some() {
@ -39,7 +39,7 @@ pub async fn create_alias_route(
delete("/_matrix/client/r0/directory/room/<_>", data = "<body>") delete("/_matrix/client/r0/directory/room/<_>", data = "<body>")
)] )]
pub async fn delete_alias_route( pub async fn delete_alias_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<delete_alias::Request<'_>>, body: Ruma<delete_alias::Request<'_>>,
) -> ConduitResult<delete_alias::Response> { ) -> ConduitResult<delete_alias::Response> {
db.rooms.set_alias(&body.room_alias, None, &db.globals)?; db.rooms.set_alias(&body.room_alias, None, &db.globals)?;
@ -54,14 +54,14 @@ pub async fn delete_alias_route(
get("/_matrix/client/r0/directory/room/<_>", data = "<body>") get("/_matrix/client/r0/directory/room/<_>", data = "<body>")
)] )]
pub async fn get_alias_route( pub async fn get_alias_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_alias::Request<'_>>, body: Ruma<get_alias::Request<'_>>,
) -> ConduitResult<get_alias::Response> { ) -> ConduitResult<get_alias::Response> {
get_alias_helper(&db, &body.room_alias).await get_alias_helper(&db, &body.room_alias).await
} }
pub async fn get_alias_helper( pub async fn get_alias_helper(
db: &Database, db: &Database<'static>,
room_alias: &RoomAliasId, room_alias: &RoomAliasId,
) -> ConduitResult<get_alias::Response> { ) -> ConduitResult<get_alias::Response> {
if room_alias.server_name() != db.globals.server_name() { if room_alias.server_name() != db.globals.server_name() {

28
src/client_server/backup.rs

@ -18,7 +18,7 @@ use rocket::{delete, get, post, put};
post("/_matrix/client/unstable/room_keys/version", data = "<body>") post("/_matrix/client/unstable/room_keys/version", data = "<body>")
)] )]
pub async fn create_backup_route( pub async fn create_backup_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<create_backup::Request>, body: Ruma<create_backup::Request>,
) -> ConduitResult<create_backup::Response> { ) -> ConduitResult<create_backup::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -36,7 +36,7 @@ pub async fn create_backup_route(
put("/_matrix/client/unstable/room_keys/version/<_>", data = "<body>") put("/_matrix/client/unstable/room_keys/version/<_>", data = "<body>")
)] )]
pub async fn update_backup_route( pub async fn update_backup_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<update_backup::Request<'_>>, body: Ruma<update_backup::Request<'_>>,
) -> ConduitResult<update_backup::Response> { ) -> ConduitResult<update_backup::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -53,7 +53,7 @@ pub async fn update_backup_route(
get("/_matrix/client/unstable/room_keys/version", data = "<body>") get("/_matrix/client/unstable/room_keys/version", data = "<body>")
)] )]
pub async fn get_latest_backup_route( pub async fn get_latest_backup_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_latest_backup::Request>, body: Ruma<get_latest_backup::Request>,
) -> ConduitResult<get_latest_backup::Response> { ) -> ConduitResult<get_latest_backup::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -80,7 +80,7 @@ pub async fn get_latest_backup_route(
get("/_matrix/client/unstable/room_keys/version/<_>", data = "<body>") get("/_matrix/client/unstable/room_keys/version/<_>", data = "<body>")
)] )]
pub async fn get_backup_route( pub async fn get_backup_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_backup::Request<'_>>, body: Ruma<get_backup::Request<'_>>,
) -> ConduitResult<get_backup::Response> { ) -> ConduitResult<get_backup::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -106,7 +106,7 @@ pub async fn get_backup_route(
delete("/_matrix/client/unstable/room_keys/version/<_>", data = "<body>") delete("/_matrix/client/unstable/room_keys/version/<_>", data = "<body>")
)] )]
pub async fn delete_backup_route( pub async fn delete_backup_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<delete_backup::Request>, body: Ruma<delete_backup::Request>,
) -> ConduitResult<delete_backup::Response> { ) -> ConduitResult<delete_backup::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -124,7 +124,7 @@ pub async fn delete_backup_route(
put("/_matrix/client/unstable/room_keys/keys", data = "<body>") put("/_matrix/client/unstable/room_keys/keys", data = "<body>")
)] )]
pub async fn add_backup_keys_route( pub async fn add_backup_keys_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<add_backup_keys::Request<'_>>, body: Ruma<add_backup_keys::Request<'_>>,
) -> ConduitResult<add_backup_keys::Response> { ) -> ConduitResult<add_backup_keys::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -157,7 +157,7 @@ pub async fn add_backup_keys_route(
put("/_matrix/client/unstable/room_keys/keys/<_>", data = "<body>") put("/_matrix/client/unstable/room_keys/keys/<_>", data = "<body>")
)] )]
pub async fn add_backup_key_sessions_route( pub async fn add_backup_key_sessions_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<add_backup_key_sessions::Request>, body: Ruma<add_backup_key_sessions::Request>,
) -> ConduitResult<add_backup_key_sessions::Response> { ) -> ConduitResult<add_backup_key_sessions::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -188,7 +188,7 @@ pub async fn add_backup_key_sessions_route(
put("/_matrix/client/unstable/room_keys/keys/<_>/<_>", data = "<body>") put("/_matrix/client/unstable/room_keys/keys/<_>/<_>", data = "<body>")
)] )]
pub async fn add_backup_key_session_route( pub async fn add_backup_key_session_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<add_backup_key_session::Request>, body: Ruma<add_backup_key_session::Request>,
) -> ConduitResult<add_backup_key_session::Response> { ) -> ConduitResult<add_backup_key_session::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -216,7 +216,7 @@ pub async fn add_backup_key_session_route(
get("/_matrix/client/unstable/room_keys/keys", data = "<body>") get("/_matrix/client/unstable/room_keys/keys", data = "<body>")
)] )]
pub async fn get_backup_keys_route( pub async fn get_backup_keys_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_backup_keys::Request<'_>>, body: Ruma<get_backup_keys::Request<'_>>,
) -> ConduitResult<get_backup_keys::Response> { ) -> ConduitResult<get_backup_keys::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -231,7 +231,7 @@ pub async fn get_backup_keys_route(
get("/_matrix/client/unstable/room_keys/keys/<_>", data = "<body>") get("/_matrix/client/unstable/room_keys/keys/<_>", data = "<body>")
)] )]
pub async fn get_backup_key_sessions_route( pub async fn get_backup_key_sessions_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_backup_key_sessions::Request>, body: Ruma<get_backup_key_sessions::Request>,
) -> ConduitResult<get_backup_key_sessions::Response> { ) -> ConduitResult<get_backup_key_sessions::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -248,7 +248,7 @@ pub async fn get_backup_key_sessions_route(
get("/_matrix/client/unstable/room_keys/keys/<_>/<_>", data = "<body>") get("/_matrix/client/unstable/room_keys/keys/<_>/<_>", data = "<body>")
)] )]
pub async fn get_backup_key_session_route( pub async fn get_backup_key_session_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_backup_key_session::Request>, body: Ruma<get_backup_key_session::Request>,
) -> ConduitResult<get_backup_key_session::Response> { ) -> ConduitResult<get_backup_key_session::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -265,7 +265,7 @@ pub async fn get_backup_key_session_route(
delete("/_matrix/client/unstable/room_keys/keys", data = "<body>") delete("/_matrix/client/unstable/room_keys/keys", data = "<body>")
)] )]
pub async fn delete_backup_keys_route( pub async fn delete_backup_keys_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<delete_backup_keys::Request>, body: Ruma<delete_backup_keys::Request>,
) -> ConduitResult<delete_backup_keys::Response> { ) -> ConduitResult<delete_backup_keys::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -287,7 +287,7 @@ pub async fn delete_backup_keys_route(
delete("/_matrix/client/unstable/room_keys/keys/<_>", data = "<body>") delete("/_matrix/client/unstable/room_keys/keys/<_>", data = "<body>")
)] )]
pub async fn delete_backup_key_sessions_route( pub async fn delete_backup_key_sessions_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<delete_backup_key_sessions::Request>, body: Ruma<delete_backup_key_sessions::Request>,
) -> ConduitResult<delete_backup_key_sessions::Response> { ) -> ConduitResult<delete_backup_key_sessions::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -309,7 +309,7 @@ pub async fn delete_backup_key_sessions_route(
delete("/_matrix/client/unstable/room_keys/keys/<_>/<_>", data = "<body>") delete("/_matrix/client/unstable/room_keys/keys/<_>/<_>", data = "<body>")
)] )]
pub async fn delete_backup_key_session_route( pub async fn delete_backup_key_session_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<delete_backup_key_session::Request>, body: Ruma<delete_backup_key_session::Request>,
) -> ConduitResult<delete_backup_key_session::Response> { ) -> ConduitResult<delete_backup_key_session::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");

4
src/client_server/config.rs

@ -17,7 +17,7 @@ use rocket::{get, put};
put("/_matrix/client/r0/user/<_>/account_data/<_>", data = "<body>") put("/_matrix/client/r0/user/<_>/account_data/<_>", data = "<body>")
)] )]
pub async fn set_global_account_data_route( pub async fn set_global_account_data_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<set_global_account_data::Request<'_>>, body: Ruma<set_global_account_data::Request<'_>>,
) -> ConduitResult<set_global_account_data::Response> { ) -> ConduitResult<set_global_account_data::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -50,7 +50,7 @@ pub async fn set_global_account_data_route(
get("/_matrix/client/r0/user/<_>/account_data/<_>", data = "<body>") get("/_matrix/client/r0/user/<_>/account_data/<_>", data = "<body>")
)] )]
pub async fn get_global_account_data_route( pub async fn get_global_account_data_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_global_account_data::Request<'_>>, body: Ruma<get_global_account_data::Request<'_>>,
) -> ConduitResult<get_global_account_data::Response> { ) -> ConduitResult<get_global_account_data::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");

2
src/client_server/context.rs

@ -11,7 +11,7 @@ use rocket::get;
get("/_matrix/client/r0/rooms/<_>/context/<_>", data = "<body>") get("/_matrix/client/r0/rooms/<_>/context/<_>", data = "<body>")
)] )]
pub async fn get_context_route( pub async fn get_context_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_context::Request<'_>>, body: Ruma<get_context::Request<'_>>,
) -> ConduitResult<get_context::Response> { ) -> ConduitResult<get_context::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");

10
src/client_server/device.rs

@ -17,7 +17,7 @@ use rocket::{delete, get, post, put};
get("/_matrix/client/r0/devices", data = "<body>") get("/_matrix/client/r0/devices", data = "<body>")
)] )]
pub async fn get_devices_route( pub async fn get_devices_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_devices::Request>, body: Ruma<get_devices::Request>,
) -> ConduitResult<get_devices::Response> { ) -> ConduitResult<get_devices::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -36,7 +36,7 @@ pub async fn get_devices_route(
get("/_matrix/client/r0/devices/<_>", data = "<body>") get("/_matrix/client/r0/devices/<_>", data = "<body>")
)] )]
pub async fn get_device_route( pub async fn get_device_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_device::Request<'_>>, body: Ruma<get_device::Request<'_>>,
) -> ConduitResult<get_device::Response> { ) -> ConduitResult<get_device::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -54,7 +54,7 @@ pub async fn get_device_route(
put("/_matrix/client/r0/devices/<_>", data = "<body>") put("/_matrix/client/r0/devices/<_>", data = "<body>")
)] )]
pub async fn update_device_route( pub async fn update_device_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<update_device::Request<'_>>, body: Ruma<update_device::Request<'_>>,
) -> ConduitResult<update_device::Response> { ) -> ConduitResult<update_device::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -79,7 +79,7 @@ pub async fn update_device_route(
delete("/_matrix/client/r0/devices/<_>", data = "<body>") delete("/_matrix/client/r0/devices/<_>", data = "<body>")
)] )]
pub async fn delete_device_route( pub async fn delete_device_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<delete_device::Request<'_>>, body: Ruma<delete_device::Request<'_>>,
) -> ConduitResult<delete_device::Response> { ) -> ConduitResult<delete_device::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -127,7 +127,7 @@ pub async fn delete_device_route(
post("/_matrix/client/r0/delete_devices", data = "<body>") post("/_matrix/client/r0/delete_devices", data = "<body>")
)] )]
pub async fn delete_devices_route( pub async fn delete_devices_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<delete_devices::Request<'_>>, body: Ruma<delete_devices::Request<'_>>,
) -> ConduitResult<delete_devices::Response> { ) -> ConduitResult<delete_devices::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");

10
src/client_server/directory.rs

@ -32,7 +32,7 @@ use rocket::{get, post, put};
post("/_matrix/client/r0/publicRooms", data = "<body>") post("/_matrix/client/r0/publicRooms", data = "<body>")
)] )]
pub async fn get_public_rooms_filtered_route( pub async fn get_public_rooms_filtered_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_public_rooms_filtered::Request<'_>>, body: Ruma<get_public_rooms_filtered::Request<'_>>,
) -> ConduitResult<get_public_rooms_filtered::Response> { ) -> ConduitResult<get_public_rooms_filtered::Response> {
get_public_rooms_filtered_helper( get_public_rooms_filtered_helper(
@ -51,7 +51,7 @@ pub async fn get_public_rooms_filtered_route(
get("/_matrix/client/r0/publicRooms", data = "<body>") get("/_matrix/client/r0/publicRooms", data = "<body>")
)] )]
pub async fn get_public_rooms_route( pub async fn get_public_rooms_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_public_rooms::Request<'_>>, body: Ruma<get_public_rooms::Request<'_>>,
) -> ConduitResult<get_public_rooms::Response> { ) -> ConduitResult<get_public_rooms::Response> {
let response = get_public_rooms_filtered_helper( let response = get_public_rooms_filtered_helper(
@ -79,7 +79,7 @@ pub async fn get_public_rooms_route(
put("/_matrix/client/r0/directory/list/room/<_>", data = "<body>") put("/_matrix/client/r0/directory/list/room/<_>", data = "<body>")
)] )]
pub async fn set_room_visibility_route( pub async fn set_room_visibility_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<set_room_visibility::Request<'_>>, body: Ruma<set_room_visibility::Request<'_>>,
) -> ConduitResult<set_room_visibility::Response> { ) -> ConduitResult<set_room_visibility::Response> {
match body.visibility { match body.visibility {
@ -97,7 +97,7 @@ pub async fn set_room_visibility_route(
get("/_matrix/client/r0/directory/list/room/<_>", data = "<body>") get("/_matrix/client/r0/directory/list/room/<_>", data = "<body>")
)] )]
pub async fn get_room_visibility_route( pub async fn get_room_visibility_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_room_visibility::Request<'_>>, body: Ruma<get_room_visibility::Request<'_>>,
) -> ConduitResult<get_room_visibility::Response> { ) -> ConduitResult<get_room_visibility::Response> {
Ok(get_room_visibility::Response { Ok(get_room_visibility::Response {
@ -111,7 +111,7 @@ pub async fn get_room_visibility_route(
} }
pub async fn get_public_rooms_filtered_helper( pub async fn get_public_rooms_filtered_helper(
db: &Database, db: &Database<'static>,
server: Option<&ServerName>, server: Option<&ServerName>,
limit: Option<js_int::UInt>, limit: Option<js_int::UInt>,
since: Option<&str>, since: Option<&str>,

12
src/client_server/keys.rs

@ -23,7 +23,7 @@ use rocket::{get, post};
post("/_matrix/client/r0/keys/upload", data = "<body>") post("/_matrix/client/r0/keys/upload", data = "<body>")
)] )]
pub async fn upload_keys_route( pub async fn upload_keys_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<upload_keys::Request<'_>>, body: Ruma<upload_keys::Request<'_>>,
) -> ConduitResult<upload_keys::Response> { ) -> ConduitResult<upload_keys::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -71,7 +71,7 @@ pub async fn upload_keys_route(
post("/_matrix/client/r0/keys/query", data = "<body>") post("/_matrix/client/r0/keys/query", data = "<body>")
)] )]
pub async fn get_keys_route( pub async fn get_keys_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_keys::Request<'_>>, body: Ruma<get_keys::Request<'_>>,
) -> ConduitResult<get_keys::Response> { ) -> ConduitResult<get_keys::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -151,7 +151,7 @@ pub async fn get_keys_route(
post("/_matrix/client/r0/keys/claim", data = "<body>") post("/_matrix/client/r0/keys/claim", data = "<body>")
)] )]
pub async fn claim_keys_route( pub async fn claim_keys_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<claim_keys::Request>, body: Ruma<claim_keys::Request>,
) -> ConduitResult<claim_keys::Response> { ) -> ConduitResult<claim_keys::Response> {
let mut one_time_keys = BTreeMap::new(); let mut one_time_keys = BTreeMap::new();
@ -184,7 +184,7 @@ pub async fn claim_keys_route(
post("/_matrix/client/unstable/keys/device_signing/upload", data = "<body>") post("/_matrix/client/unstable/keys/device_signing/upload", data = "<body>")
)] )]
pub async fn upload_signing_keys_route( pub async fn upload_signing_keys_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<upload_signing_keys::Request<'_>>, body: Ruma<upload_signing_keys::Request<'_>>,
) -> ConduitResult<upload_signing_keys::Response> { ) -> ConduitResult<upload_signing_keys::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -241,7 +241,7 @@ pub async fn upload_signing_keys_route(
post("/_matrix/client/unstable/keys/signatures/upload", data = "<body>") post("/_matrix/client/unstable/keys/signatures/upload", data = "<body>")
)] )]
pub async fn upload_signatures_route( pub async fn upload_signatures_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<upload_signatures::Request>, body: Ruma<upload_signatures::Request>,
) -> ConduitResult<upload_signatures::Response> { ) -> ConduitResult<upload_signatures::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -301,7 +301,7 @@ pub async fn upload_signatures_route(
get("/_matrix/client/r0/keys/changes", data = "<body>") get("/_matrix/client/r0/keys/changes", data = "<body>")
)] )]
pub async fn get_key_changes_route( pub async fn get_key_changes_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_key_changes::Request<'_>>, body: Ruma<get_key_changes::Request<'_>>,
) -> ConduitResult<get_key_changes::Response> { ) -> ConduitResult<get_key_changes::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");

8
src/client_server/media.rs

@ -15,7 +15,7 @@ const MXC_LENGTH: usize = 32;
#[cfg_attr(feature = "conduit_bin", get("/_matrix/media/r0/config"))] #[cfg_attr(feature = "conduit_bin", get("/_matrix/media/r0/config"))]
pub async fn get_media_config_route( pub async fn get_media_config_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
) -> ConduitResult<get_media_config::Response> { ) -> ConduitResult<get_media_config::Response> {
Ok(get_media_config::Response { Ok(get_media_config::Response {
upload_size: db.globals.max_request_size().into(), upload_size: db.globals.max_request_size().into(),
@ -28,7 +28,7 @@ pub async fn get_media_config_route(
post("/_matrix/media/r0/upload", data = "<body>") post("/_matrix/media/r0/upload", data = "<body>")
)] )]
pub async fn create_content_route( pub async fn create_content_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<create_content::Request<'_>>, body: Ruma<create_content::Request<'_>>,
) -> ConduitResult<create_content::Response> { ) -> ConduitResult<create_content::Response> {
let mxc = format!( let mxc = format!(
@ -53,7 +53,7 @@ pub async fn create_content_route(
get("/_matrix/media/r0/download/<_>/<_>", data = "<body>") get("/_matrix/media/r0/download/<_>/<_>", data = "<body>")
)] )]
pub async fn get_content_route( pub async fn get_content_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_content::Request<'_>>, body: Ruma<get_content::Request<'_>>,
) -> ConduitResult<get_content::Response> { ) -> ConduitResult<get_content::Response> {
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id); let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
@ -100,7 +100,7 @@ pub async fn get_content_route(
get("/_matrix/media/r0/thumbnail/<_>/<_>", data = "<body>") get("/_matrix/media/r0/thumbnail/<_>/<_>", data = "<body>")
)] )]
pub async fn get_content_thumbnail_route( pub async fn get_content_thumbnail_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_content_thumbnail::Request<'_>>, body: Ruma<get_content_thumbnail::Request<'_>>,
) -> ConduitResult<get_content_thumbnail::Response> { ) -> ConduitResult<get_content_thumbnail::Response> {
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id); let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);

24
src/client_server/membership.rs

@ -35,7 +35,7 @@ use rocket::{get, post};
post("/_matrix/client/r0/rooms/<_>/join", data = "<body>") post("/_matrix/client/r0/rooms/<_>/join", data = "<body>")
)] )]
pub async fn join_room_by_id_route( pub async fn join_room_by_id_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<join_room_by_id::Request<'_>>, body: Ruma<join_room_by_id::Request<'_>>,
) -> ConduitResult<join_room_by_id::Response> { ) -> ConduitResult<join_room_by_id::Response> {
join_room_by_id_helper( join_room_by_id_helper(
@ -53,7 +53,7 @@ pub async fn join_room_by_id_route(
post("/_matrix/client/r0/join/<_>", data = "<body>") post("/_matrix/client/r0/join/<_>", data = "<body>")
)] )]
pub async fn join_room_by_id_or_alias_route( pub async fn join_room_by_id_or_alias_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<join_room_by_id_or_alias::Request<'_>>, body: Ruma<join_room_by_id_or_alias::Request<'_>>,
) -> ConduitResult<join_room_by_id_or_alias::Response> { ) -> ConduitResult<join_room_by_id_or_alias::Response> {
let (servers, room_id) = match RoomId::try_from(body.room_id_or_alias.clone()) { let (servers, room_id) = match RoomId::try_from(body.room_id_or_alias.clone()) {
@ -87,7 +87,7 @@ pub async fn join_room_by_id_or_alias_route(
post("/_matrix/client/r0/rooms/<_>/leave", data = "<body>") post("/_matrix/client/r0/rooms/<_>/leave", data = "<body>")
)] )]
pub async fn leave_room_route( pub async fn leave_room_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<leave_room::Request<'_>>, body: Ruma<leave_room::Request<'_>>,
) -> ConduitResult<leave_room::Response> { ) -> ConduitResult<leave_room::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -138,7 +138,7 @@ pub async fn leave_room_route(
post("/_matrix/client/r0/rooms/<_>/invite", data = "<body>") post("/_matrix/client/r0/rooms/<_>/invite", data = "<body>")
)] )]
pub async fn invite_user_route( pub async fn invite_user_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<invite_user::Request<'_>>, body: Ruma<invite_user::Request<'_>>,
) -> ConduitResult<invite_user::Response> { ) -> ConduitResult<invite_user::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -180,7 +180,7 @@ pub async fn invite_user_route(
post("/_matrix/client/r0/rooms/<_>/kick", data = "<body>") post("/_matrix/client/r0/rooms/<_>/kick", data = "<body>")
)] )]
pub async fn kick_user_route( pub async fn kick_user_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<kick_user::Request<'_>>, body: Ruma<kick_user::Request<'_>>,
) -> ConduitResult<kick_user::Response> { ) -> ConduitResult<kick_user::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -232,7 +232,7 @@ pub async fn kick_user_route(
post("/_matrix/client/r0/rooms/<_>/ban", data = "<body>") post("/_matrix/client/r0/rooms/<_>/ban", data = "<body>")
)] )]
pub async fn ban_user_route( pub async fn ban_user_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<ban_user::Request<'_>>, body: Ruma<ban_user::Request<'_>>,
) -> ConduitResult<ban_user::Response> { ) -> ConduitResult<ban_user::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -291,7 +291,7 @@ pub async fn ban_user_route(
post("/_matrix/client/r0/rooms/<_>/unban", data = "<body>") post("/_matrix/client/r0/rooms/<_>/unban", data = "<body>")
)] )]
pub async fn unban_user_route( pub async fn unban_user_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<unban_user::Request<'_>>, body: Ruma<unban_user::Request<'_>>,
) -> ConduitResult<unban_user::Response> { ) -> ConduitResult<unban_user::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -342,7 +342,7 @@ pub async fn unban_user_route(
post("/_matrix/client/r0/rooms/<_>/forget", data = "<body>") post("/_matrix/client/r0/rooms/<_>/forget", data = "<body>")
)] )]
pub async fn forget_room_route( pub async fn forget_room_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<forget_room::Request<'_>>, body: Ruma<forget_room::Request<'_>>,
) -> ConduitResult<forget_room::Response> { ) -> ConduitResult<forget_room::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -359,7 +359,7 @@ pub async fn forget_room_route(
get("/_matrix/client/r0/joined_rooms", data = "<body>") get("/_matrix/client/r0/joined_rooms", data = "<body>")
)] )]
pub async fn joined_rooms_route( pub async fn joined_rooms_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<joined_rooms::Request>, body: Ruma<joined_rooms::Request>,
) -> ConduitResult<joined_rooms::Response> { ) -> ConduitResult<joined_rooms::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -379,7 +379,7 @@ pub async fn joined_rooms_route(
get("/_matrix/client/r0/rooms/<_>/members", data = "<body>") get("/_matrix/client/r0/rooms/<_>/members", data = "<body>")
)] )]
pub async fn get_member_events_route( pub async fn get_member_events_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_member_events::Request<'_>>, body: Ruma<get_member_events::Request<'_>>,
) -> ConduitResult<get_member_events::Response> { ) -> ConduitResult<get_member_events::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -407,7 +407,7 @@ pub async fn get_member_events_route(
get("/_matrix/client/r0/rooms/<_>/joined_members", data = "<body>") get("/_matrix/client/r0/rooms/<_>/joined_members", data = "<body>")
)] )]
pub async fn joined_members_route( pub async fn joined_members_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<joined_members::Request<'_>>, body: Ruma<joined_members::Request<'_>>,
) -> ConduitResult<joined_members::Response> { ) -> ConduitResult<joined_members::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -441,7 +441,7 @@ pub async fn joined_members_route(
} }
async fn join_room_by_id_helper( async fn join_room_by_id_helper(
db: &Database, db: &Database<'static>,
sender_user: Option<&UserId>, sender_user: Option<&UserId>,
room_id: &RoomId, room_id: &RoomId,
servers: &[Box<ServerName>], servers: &[Box<ServerName>],

4
src/client_server/message.rs

@ -18,7 +18,7 @@ use rocket::{get, put};
put("/_matrix/client/r0/rooms/<_>/send/<_>/<_>", data = "<body>") put("/_matrix/client/r0/rooms/<_>/send/<_>/<_>", data = "<body>")
)] )]
pub async fn send_message_event_route( pub async fn send_message_event_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<send_message_event::Request<'_>>, body: Ruma<send_message_event::Request<'_>>,
) -> ConduitResult<send_message_event::Response> { ) -> ConduitResult<send_message_event::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -88,7 +88,7 @@ pub async fn send_message_event_route(
get("/_matrix/client/r0/rooms/<_>/messages", data = "<body>") get("/_matrix/client/r0/rooms/<_>/messages", data = "<body>")
)] )]
pub async fn get_message_events_route( pub async fn get_message_events_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_message_events::Request<'_>>, body: Ruma<get_message_events::Request<'_>>,
) -> ConduitResult<get_message_events::Response> { ) -> ConduitResult<get_message_events::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");

2
src/client_server/presence.rs

@ -11,7 +11,7 @@ use rocket::put;
put("/_matrix/client/r0/presence/<_>/status", data = "<body>") put("/_matrix/client/r0/presence/<_>/status", data = "<body>")
)] )]
pub async fn set_presence_route( pub async fn set_presence_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<set_presence::Request<'_>>, body: Ruma<set_presence::Request<'_>>,
) -> ConduitResult<set_presence::Response> { ) -> ConduitResult<set_presence::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");

10
src/client_server/profile.rs

@ -20,7 +20,7 @@ use std::convert::TryInto;
put("/_matrix/client/r0/profile/<_>/displayname", data = "<body>") put("/_matrix/client/r0/profile/<_>/displayname", data = "<body>")
)] )]
pub async fn set_displayname_route( pub async fn set_displayname_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<set_display_name::Request<'_>>, body: Ruma<set_display_name::Request<'_>>,
) -> ConduitResult<set_display_name::Response> { ) -> ConduitResult<set_display_name::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -102,7 +102,7 @@ pub async fn set_displayname_route(
get("/_matrix/client/r0/profile/<_>/displayname", data = "<body>") get("/_matrix/client/r0/profile/<_>/displayname", data = "<body>")
)] )]
pub async fn get_displayname_route( pub async fn get_displayname_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_display_name::Request<'_>>, body: Ruma<get_display_name::Request<'_>>,
) -> ConduitResult<get_display_name::Response> { ) -> ConduitResult<get_display_name::Response> {
Ok(get_display_name::Response { Ok(get_display_name::Response {
@ -116,7 +116,7 @@ pub async fn get_displayname_route(
put("/_matrix/client/r0/profile/<_>/avatar_url", data = "<body>") put("/_matrix/client/r0/profile/<_>/avatar_url", data = "<body>")
)] )]
pub async fn set_avatar_url_route( pub async fn set_avatar_url_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<set_avatar_url::Request<'_>>, body: Ruma<set_avatar_url::Request<'_>>,
) -> ConduitResult<set_avatar_url::Response> { ) -> ConduitResult<set_avatar_url::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -198,7 +198,7 @@ pub async fn set_avatar_url_route(
get("/_matrix/client/r0/profile/<_>/avatar_url", data = "<body>") get("/_matrix/client/r0/profile/<_>/avatar_url", data = "<body>")
)] )]
pub async fn get_avatar_url_route( pub async fn get_avatar_url_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_avatar_url::Request<'_>>, body: Ruma<get_avatar_url::Request<'_>>,
) -> ConduitResult<get_avatar_url::Response> { ) -> ConduitResult<get_avatar_url::Response> {
Ok(get_avatar_url::Response { Ok(get_avatar_url::Response {
@ -212,7 +212,7 @@ pub async fn get_avatar_url_route(
get("/_matrix/client/r0/profile/<_>", data = "<body>") get("/_matrix/client/r0/profile/<_>", data = "<body>")
)] )]
pub async fn get_profile_route( pub async fn get_profile_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_profile::Request<'_>>, body: Ruma<get_profile::Request<'_>>,
) -> ConduitResult<get_profile::Response> { ) -> ConduitResult<get_profile::Response> {
if !db.users.exists(&body.user_id)? { if !db.users.exists(&body.user_id)? {

8
src/client_server/push.rs

@ -17,7 +17,7 @@ use rocket::{get, post, put};
get("/_matrix/client/r0/pushrules", data = "<body>") get("/_matrix/client/r0/pushrules", data = "<body>")
)] )]
pub async fn get_pushrules_all_route( pub async fn get_pushrules_all_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_pushrules_all::Request>, body: Ruma<get_pushrules_all::Request>,
) -> ConduitResult<get_pushrules_all::Response> { ) -> ConduitResult<get_pushrules_all::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -41,7 +41,7 @@ pub async fn get_pushrules_all_route(
//data = "<body>" //data = "<body>"
))] ))]
pub async fn set_pushrule_route( pub async fn set_pushrule_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
//body: Ruma<set_pushrule::Request>, //body: Ruma<set_pushrule::Request>,
) -> ConduitResult<set_pushrule::Response> { ) -> ConduitResult<set_pushrule::Response> {
// TODO // TODO
@ -57,7 +57,7 @@ pub async fn set_pushrule_route(
put("/_matrix/client/r0/pushrules/<_>/<_>/<_>/enabled") put("/_matrix/client/r0/pushrules/<_>/<_>/<_>/enabled")
)] )]
pub async fn set_pushrule_enabled_route( pub async fn set_pushrule_enabled_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
) -> ConduitResult<set_pushrule_enabled::Response> { ) -> ConduitResult<set_pushrule_enabled::Response> {
// TODO // TODO
warn!("TODO: set_pushrule_enabled_route"); warn!("TODO: set_pushrule_enabled_route");
@ -76,7 +76,7 @@ pub async fn get_pushers_route() -> ConduitResult<get_pushers::Response> {
} }
#[cfg_attr(feature = "conduit_bin", post("/_matrix/client/r0/pushers/set"))] #[cfg_attr(feature = "conduit_bin", post("/_matrix/client/r0/pushers/set"))]
pub async fn set_pushers_route(db: State<'_, Database>) -> ConduitResult<get_pushers::Response> { pub async fn set_pushers_route(db: State<'_, Database<'_>>) -> ConduitResult<get_pushers::Response> {
db.flush().await?; db.flush().await?;
Ok(get_pushers::Response { Ok(get_pushers::Response {

2
src/client_server/read_marker.rs

@ -14,7 +14,7 @@ use std::{collections::BTreeMap, time::SystemTime};
post("/_matrix/client/r0/rooms/<_>/read_markers", data = "<body>") post("/_matrix/client/r0/rooms/<_>/read_markers", data = "<body>")
)] )]
pub async fn set_read_marker_route( pub async fn set_read_marker_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<set_read_marker::Request<'_>>, body: Ruma<set_read_marker::Request<'_>>,
) -> ConduitResult<set_read_marker::Response> { ) -> ConduitResult<set_read_marker::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");

2
src/client_server/redact.rs

@ -13,7 +13,7 @@ use rocket::put;
put("/_matrix/client/r0/rooms/<_>/redact/<_>/<_>", data = "<body>") put("/_matrix/client/r0/rooms/<_>/redact/<_>/<_>", data = "<body>")
)] )]
pub async fn redact_event_route( pub async fn redact_event_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<redact_event::Request<'_>>, body: Ruma<redact_event::Request<'_>>,
) -> ConduitResult<redact_event::Response> { ) -> ConduitResult<redact_event::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");

6
src/client_server/room.rs

@ -21,7 +21,7 @@ use rocket::{get, post};
post("/_matrix/client/r0/createRoom", data = "<body>") post("/_matrix/client/r0/createRoom", data = "<body>")
)] )]
pub async fn create_room_route( pub async fn create_room_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<create_room::Request<'_>>, body: Ruma<create_room::Request<'_>>,
) -> ConduitResult<create_room::Response> { ) -> ConduitResult<create_room::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -333,7 +333,7 @@ pub async fn create_room_route(
get("/_matrix/client/r0/rooms/<_>/event/<_>", data = "<body>") get("/_matrix/client/r0/rooms/<_>/event/<_>", data = "<body>")
)] )]
pub async fn get_room_event_route( pub async fn get_room_event_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_room_event::Request<'_>>, body: Ruma<get_room_event::Request<'_>>,
) -> ConduitResult<get_room_event::Response> { ) -> ConduitResult<get_room_event::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -360,7 +360,7 @@ pub async fn get_room_event_route(
post("/_matrix/client/r0/rooms/<_room_id>/upgrade", data = "<body>") post("/_matrix/client/r0/rooms/<_room_id>/upgrade", data = "<body>")
)] )]
pub async fn upgrade_room_route( pub async fn upgrade_room_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<upgrade_room::Request<'_>>, body: Ruma<upgrade_room::Request<'_>>,
_room_id: String, _room_id: String,
) -> ConduitResult<upgrade_room::Response> { ) -> ConduitResult<upgrade_room::Response> {

2
src/client_server/search.rs

@ -12,7 +12,7 @@ use std::collections::BTreeMap;
post("/_matrix/client/r0/search", data = "<body>") post("/_matrix/client/r0/search", data = "<body>")
)] )]
pub async fn search_events_route( pub async fn search_events_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<search_events::Request<'_>>, body: Ruma<search_events::Request<'_>>,
) -> ConduitResult<search_events::Response> { ) -> ConduitResult<search_events::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");

66
src/client_server/session.rs

@ -7,6 +7,13 @@ use ruma::{
}, },
UserId, UserId,
}; };
use serde::Deserialize;
#[derive(Debug, Deserialize)]
struct Claims {
sub: String,
exp: usize,
}
#[cfg(feature = "conduit_bin")] #[cfg(feature = "conduit_bin")]
use rocket::{get, post}; use rocket::{get, post};
@ -35,43 +42,60 @@ pub async fn get_login_types_route() -> ConduitResult<get_login_types::Response>
post("/_matrix/client/r0/login", data = "<body>") post("/_matrix/client/r0/login", data = "<body>")
)] )]
pub async fn login_route( pub async fn login_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<login::Request<'_>>, body: Ruma<login::Request<'_>>,
) -> ConduitResult<login::Response> { ) -> ConduitResult<login::Response> {
// Validate login method // Validate login method
let user_id = let user_id = match &body.login_info {
// TODO: Other login methods login::IncomingLoginInfo::Password { password } => {
if let (login::IncomingUserInfo::MatrixId(username), login::IncomingLoginInfo::Password { password }) = let username = if let login::IncomingUserInfo::MatrixId(matrix_id) = &body.user {
(&body.user, &body.login_info) matrix_id
{ } else {
let user_id = UserId::parse_with_server_name(username.to_string(), db.globals.server_name()) return Err(Error::BadRequest(ErrorKind::Forbidden, "Bad login type."));
.map_err(|_| Error::BadRequest( };
ErrorKind::InvalidUsername, let user_id = UserId::parse_with_server_name(username.to_owned(), db.globals.server_name())
"Username is invalid." .map_err(|_| {
))?; Error::BadRequest(ErrorKind::InvalidUsername, "Username is invalid.")
let hash = db.users.password_hash(&user_id)? })?;
.ok_or(Error::BadRequest( let hash = db.users.password_hash(&user_id)?.ok_or(Error::BadRequest(
ErrorKind::Forbidden, ErrorKind::Forbidden,
"Wrong username or password." "Wrong username or password.",
))?; ))?;
if hash.is_empty() { if hash.is_empty() {
return Err(Error::BadRequest( return Err(Error::BadRequest(
ErrorKind::UserDeactivated, ErrorKind::UserDeactivated,
"The user has been deactivated" "The user has been deactivated",
)); ));
} }
let hash_matches = let hash_matches = argon2::verify_encoded(&hash, password.as_bytes()).unwrap_or(false);
argon2::verify_encoded(&hash, password.as_bytes()).unwrap_or(false);
if !hash_matches { if !hash_matches {
return Err(Error::BadRequest(ErrorKind::Forbidden, "Wrong username or password.")); return Err(Error::BadRequest(
ErrorKind::Forbidden,
"Wrong username or password.",
));
} }
user_id user_id
}
login::IncomingLoginInfo::Token { token } => {
if let Some(jwt_decoding_key) = db.globals.jwt_decoding_key() {
let token = jsonwebtoken::decode::<Claims>(
&token,
&jwt_decoding_key,
&jsonwebtoken::Validation::default(),
)
.map_err(|_| Error::BadRequest(ErrorKind::InvalidUsername, "Token is invalid."))?;
let username = token.claims.sub;
UserId::parse_with_server_name(username, db.globals.server_name()).map_err(|_| {
Error::BadRequest(ErrorKind::InvalidUsername, "Username is invalid.")
})?
} else { } else {
return Err(Error::BadRequest(ErrorKind::Forbidden, "Bad login type.")); return Err(Error::BadRequest(ErrorKind::Unknown, "Token login is not supported (server has no jwt decoding key)."));
}
}
}; };
// Generate new device id if the user didn't specify one // Generate new device id if the user didn't specify one
@ -116,7 +140,7 @@ pub async fn login_route(
post("/_matrix/client/r0/logout", data = "<body>") post("/_matrix/client/r0/logout", data = "<body>")
)] )]
pub async fn logout_route( pub async fn logout_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<logout::Request>, body: Ruma<logout::Request>,
) -> ConduitResult<logout::Response> { ) -> ConduitResult<logout::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -143,7 +167,7 @@ pub async fn logout_route(
post("/_matrix/client/r0/logout/all", data = "<body>") post("/_matrix/client/r0/logout/all", data = "<body>")
)] )]
pub async fn logout_all_route( pub async fn logout_all_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<logout_all::Request>, body: Ruma<logout_all::Request>,
) -> ConduitResult<logout_all::Response> { ) -> ConduitResult<logout_all::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");

12
src/client_server/state.rs

@ -24,7 +24,7 @@ use rocket::{get, put};
put("/_matrix/client/r0/rooms/<_>/state/<_>/<_>", data = "<body>") put("/_matrix/client/r0/rooms/<_>/state/<_>/<_>", data = "<body>")
)] )]
pub async fn send_state_event_for_key_route( pub async fn send_state_event_for_key_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<send_state_event_for_key::Request<'_>>, body: Ruma<send_state_event_for_key::Request<'_>>,
) -> ConduitResult<send_state_event_for_key::Response> { ) -> ConduitResult<send_state_event_for_key::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -57,7 +57,7 @@ pub async fn send_state_event_for_key_route(
put("/_matrix/client/r0/rooms/<_>/state/<_>", data = "<body>") put("/_matrix/client/r0/rooms/<_>/state/<_>", data = "<body>")
)] )]
pub async fn send_state_event_for_empty_key_route( pub async fn send_state_event_for_empty_key_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<send_state_event_for_empty_key::Request<'_>>, body: Ruma<send_state_event_for_empty_key::Request<'_>>,
) -> ConduitResult<send_state_event_for_empty_key::Response> { ) -> ConduitResult<send_state_event_for_empty_key::Response> {
// This just calls send_state_event_for_key_route // This just calls send_state_event_for_key_route
@ -98,7 +98,7 @@ pub async fn send_state_event_for_empty_key_route(
get("/_matrix/client/r0/rooms/<_>/state", data = "<body>") get("/_matrix/client/r0/rooms/<_>/state", data = "<body>")
)] )]
pub async fn get_state_events_route( pub async fn get_state_events_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_state_events::Request>, body: Ruma<get_state_events::Request>,
) -> ConduitResult<get_state_events::Response> { ) -> ConduitResult<get_state_events::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -143,7 +143,7 @@ pub async fn get_state_events_route(
get("/_matrix/client/r0/rooms/<_>/state/<_>/<_>", data = "<body>") get("/_matrix/client/r0/rooms/<_>/state/<_>/<_>", data = "<body>")
)] )]
pub async fn get_state_events_for_key_route( pub async fn get_state_events_for_key_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_state_events_for_key::Request>, body: Ruma<get_state_events_for_key::Request>,
) -> ConduitResult<get_state_events_for_key::Response> { ) -> ConduitResult<get_state_events_for_key::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -193,7 +193,7 @@ pub async fn get_state_events_for_key_route(
get("/_matrix/client/r0/rooms/<_>/state/<_>", data = "<body>") get("/_matrix/client/r0/rooms/<_>/state/<_>", data = "<body>")
)] )]
pub async fn get_state_events_for_empty_key_route( pub async fn get_state_events_for_empty_key_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_state_events_for_empty_key::Request>, body: Ruma<get_state_events_for_empty_key::Request>,
) -> ConduitResult<get_state_events_for_empty_key::Response> { ) -> ConduitResult<get_state_events_for_empty_key::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -239,7 +239,7 @@ pub async fn get_state_events_for_empty_key_route(
} }
pub async fn send_state_event_for_key_helper( pub async fn send_state_event_for_key_helper(
db: &Database, db: &Database<'_>,
sender: &UserId, sender: &UserId,
content: &AnyStateEventContent, content: &AnyStateEventContent,
json: serde_json::Value, json: serde_json::Value,

4
src/client_server/sync.rs

@ -30,7 +30,7 @@ use std::{
get("/_matrix/client/r0/sync", data = "<body>") get("/_matrix/client/r0/sync", data = "<body>")
)] )]
pub async fn sync_events_route( pub async fn sync_events_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<sync_events::Request<'_>>, body: Ruma<sync_events::Request<'_>>,
) -> ConduitResult<sync_events::Response> { ) -> ConduitResult<sync_events::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -661,7 +661,7 @@ pub async fn sync_events_route(
} }
fn share_encrypted_room( fn share_encrypted_room(
db: &Database, db: &Database<'_>,
sender_user: &UserId, sender_user: &UserId,
user_id: &UserId, user_id: &UserId,
ignore_room: &RoomId, ignore_room: &RoomId,

6
src/client_server/tag.rs

@ -14,7 +14,7 @@ use rocket::{delete, get, put};
put("/_matrix/client/r0/user/<_>/rooms/<_>/tags/<_>", data = "<body>") put("/_matrix/client/r0/user/<_>/rooms/<_>/tags/<_>", data = "<body>")
)] )]
pub async fn update_tag_route( pub async fn update_tag_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<create_tag::Request<'_>>, body: Ruma<create_tag::Request<'_>>,
) -> ConduitResult<create_tag::Response> { ) -> ConduitResult<create_tag::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -50,7 +50,7 @@ pub async fn update_tag_route(
delete("/_matrix/client/r0/user/<_>/rooms/<_>/tags/<_>", data = "<body>") delete("/_matrix/client/r0/user/<_>/rooms/<_>/tags/<_>", data = "<body>")
)] )]
pub async fn delete_tag_route( pub async fn delete_tag_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<delete_tag::Request<'_>>, body: Ruma<delete_tag::Request<'_>>,
) -> ConduitResult<delete_tag::Response> { ) -> ConduitResult<delete_tag::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -83,7 +83,7 @@ pub async fn delete_tag_route(
get("/_matrix/client/r0/user/<_>/rooms/<_>/tags", data = "<body>") get("/_matrix/client/r0/user/<_>/rooms/<_>/tags", data = "<body>")
)] )]
pub async fn get_tags_route( pub async fn get_tags_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_tags::Request<'_>>, body: Ruma<get_tags::Request<'_>>,
) -> ConduitResult<get_tags::Response> { ) -> ConduitResult<get_tags::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");

2
src/client_server/to_device.rs

@ -13,7 +13,7 @@ use rocket::put;
put("/_matrix/client/r0/sendToDevice/<_>/<_>", data = "<body>") put("/_matrix/client/r0/sendToDevice/<_>/<_>", data = "<body>")
)] )]
pub async fn send_event_to_device_route( pub async fn send_event_to_device_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<send_event_to_device::Request<'_>>, body: Ruma<send_event_to_device::Request<'_>>,
) -> ConduitResult<send_event_to_device::Response> { ) -> ConduitResult<send_event_to_device::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");

2
src/client_server/typing.rs

@ -11,7 +11,7 @@ use rocket::put;
put("/_matrix/client/r0/rooms/<_>/typing/<_>", data = "<body>") put("/_matrix/client/r0/rooms/<_>/typing/<_>", data = "<body>")
)] )]
pub fn create_typing_event_route( pub fn create_typing_event_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<create_typing_event::Request<'_>>, body: Ruma<create_typing_event::Request<'_>>,
) -> ConduitResult<create_typing_event::Response> { ) -> ConduitResult<create_typing_event::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");

2
src/client_server/user_directory.rs

@ -10,7 +10,7 @@ use rocket::post;
post("/_matrix/client/r0/user_directory/search", data = "<body>") post("/_matrix/client/r0/user_directory/search", data = "<body>")
)] )]
pub async fn search_users_route( pub async fn search_users_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<search_users::Request<'_>>, body: Ruma<search_users::Request<'_>>,
) -> ConduitResult<search_users::Response> { ) -> ConduitResult<search_users::Response> {
let limit = u64::from(body.limit) as usize; let limit = u64::from(body.limit) as usize;

6
src/database.rs

@ -21,8 +21,8 @@ use ruma::{DeviceId, UserId};
use std::{convert::TryFrom, fs::remove_dir_all}; use std::{convert::TryFrom, fs::remove_dir_all};
#[derive(Clone)] #[derive(Clone)]
pub struct Database { pub struct Database<'a> {
pub globals: globals::Globals, pub globals: globals::Globals<'a>,
pub users: users::Users, pub users: users::Users,
pub uiaa: uiaa::Uiaa, pub uiaa: uiaa::Uiaa,
pub rooms: rooms::Rooms, pub rooms: rooms::Rooms,
@ -35,7 +35,7 @@ pub struct Database {
pub _db: sled::Db, pub _db: sled::Db,
} }
impl Database { impl Database<'static> {
/// Tries to remove the old database but ignores all errors. /// Tries to remove the old database but ignores all errors.
pub fn try_remove(server_name: &str) -> Result<()> { pub fn try_remove(server_name: &str) -> Result<()> {
let mut path = ProjectDirs::from("xyz", "koesters", "conduit") let mut path = ProjectDirs::from("xyz", "koesters", "conduit")

2
src/database/account_data.rs

@ -21,7 +21,7 @@ impl AccountData {
user_id: &UserId, user_id: &UserId,
event_type: EventType, event_type: EventType,
data: &T, data: &T,
globals: &super::globals::Globals, globals: &super::globals::Globals<'_>,
) -> Result<()> { ) -> Result<()> {
let mut prefix = room_id let mut prefix = room_id
.map(|r| r.to_string()) .map(|r| r.to_string())

2
src/database/admin.rs

@ -17,7 +17,7 @@ pub struct Admin {
impl Admin { impl Admin {
pub fn start_handler( pub fn start_handler(
&self, &self,
db: super::Database, db: super::Database<'static>,
mut receiver: mpsc::UnboundedReceiver<AdminCommand>, mut receiver: mpsc::UnboundedReceiver<AdminCommand>,
) { ) {
tokio::spawn(async move { tokio::spawn(async move {

19
src/database/globals.rs

@ -6,7 +6,7 @@ use std::{convert::TryInto, sync::Arc};
pub const COUNTER: &str = "c"; pub const COUNTER: &str = "c";
#[derive(Clone)] #[derive(Clone)]
pub struct Globals { pub struct Globals<'a> {
pub(super) globals: sled::Tree, pub(super) globals: sled::Tree,
keypair: Arc<ruma::signatures::Ed25519KeyPair>, keypair: Arc<ruma::signatures::Ed25519KeyPair>,
reqwest_client: reqwest::Client, reqwest_client: reqwest::Client,
@ -15,9 +15,10 @@ pub struct Globals {
registration_disabled: bool, registration_disabled: bool,
encryption_disabled: bool, encryption_disabled: bool,
federation_enabled: bool, federation_enabled: bool,
jwt_decoding_key: Option<jsonwebtoken::DecodingKey<'a>>,
} }
impl Globals { impl Globals<'_> {
pub fn load(globals: sled::Tree, config: &rocket::Config) -> Result<Self> { pub fn load(globals: sled::Tree, config: &rocket::Config) -> Result<Self> {
let bytes = &*globals let bytes = &*globals
.update_and_fetch("keypair", utils::generate_keypair)? .update_and_fetch("keypair", utils::generate_keypair)?
@ -53,14 +54,19 @@ impl Globals {
} }
}; };
let jwt_decoding_key =
config.get_str("jwt_secret").map(|secret| jsonwebtoken::DecodingKey::from_secret(secret.as_bytes()).into_static()).ok();
Ok(Self { Ok(Self {
globals, globals,
keypair: Arc::new(keypair), keypair: Arc::new(keypair),
reqwest_client: reqwest::Client::new(), reqwest_client: reqwest::Client::new(),
server_name: config server_name: config
.get_str("server_name") .get_str("server_name")
.unwrap_or("localhost") .map(std::string::ToString::to_string)
.to_string() .unwrap_or_else(|_| {
std::env::var("SERVER_NAME").unwrap_or_else(|_| "localhost".to_string())
})
.try_into() .try_into()
.map_err(|_| Error::BadConfig("Invalid server_name."))?, .map_err(|_| Error::BadConfig("Invalid server_name."))?,
max_request_size: config max_request_size: config
@ -71,6 +77,7 @@ impl Globals {
registration_disabled: config.get_bool("registration_disabled").unwrap_or(false), registration_disabled: config.get_bool("registration_disabled").unwrap_or(false),
encryption_disabled: config.get_bool("encryption_disabled").unwrap_or(false), encryption_disabled: config.get_bool("encryption_disabled").unwrap_or(false),
federation_enabled: config.get_bool("federation_enabled").unwrap_or(false), federation_enabled: config.get_bool("federation_enabled").unwrap_or(false),
jwt_decoding_key,
}) })
} }
@ -120,4 +127,8 @@ impl Globals {
pub fn federation_enabled(&self) -> bool { pub fn federation_enabled(&self) -> bool {
self.federation_enabled self.federation_enabled
} }
pub fn jwt_decoding_key(&self) -> Option<&jsonwebtoken::DecodingKey<'_>> {
self.jwt_decoding_key.as_ref()
}
} }

6
src/database/key_backups.rs

@ -20,7 +20,7 @@ impl KeyBackups {
&self, &self,
user_id: &UserId, user_id: &UserId,
backup_metadata: &BackupAlgorithm, backup_metadata: &BackupAlgorithm,
globals: &super::globals::Globals, globals: &super::globals::Globals<'_>,
) -> Result<String> { ) -> Result<String> {
let version = globals.next_count()?.to_string(); let version = globals.next_count()?.to_string();
@ -65,7 +65,7 @@ impl KeyBackups {
user_id: &UserId, user_id: &UserId,
version: &str, version: &str,
backup_metadata: &BackupAlgorithm, backup_metadata: &BackupAlgorithm,
globals: &super::globals::Globals, globals: &super::globals::Globals<'_>,
) -> Result<String> { ) -> Result<String> {
let mut key = user_id.to_string().as_bytes().to_vec(); let mut key = user_id.to_string().as_bytes().to_vec();
key.push(0xff); key.push(0xff);
@ -130,7 +130,7 @@ impl KeyBackups {
room_id: &RoomId, room_id: &RoomId,
session_id: &str, session_id: &str,
key_data: &KeyData, key_data: &KeyData,
globals: &super::globals::Globals, globals: &super::globals::Globals<'_>,
) -> Result<()> { ) -> Result<()> {
let mut key = user_id.to_string().as_bytes().to_vec(); let mut key = user_id.to_string().as_bytes().to_vec();
key.push(0xff); key.push(0xff);

8
src/database/rooms.rs

@ -443,7 +443,7 @@ impl Rooms {
pdu_json: &serde_json::Value, pdu_json: &serde_json::Value,
count: u64, count: u64,
pdu_id: IVec, pdu_id: IVec,
globals: &super::globals::Globals, globals: &super::globals::Globals<'_>,
account_data: &super::account_data::AccountData, account_data: &super::account_data::AccountData,
admin: &super::admin::Admin, admin: &super::admin::Admin,
) -> Result<()> { ) -> Result<()> {
@ -597,7 +597,7 @@ impl Rooms {
pdu_builder: PduBuilder, pdu_builder: PduBuilder,
sender: &UserId, sender: &UserId,
room_id: &RoomId, room_id: &RoomId,
globals: &super::globals::Globals, globals: &super::globals::Globals<'_>,
sending: &super::sending::Sending, sending: &super::sending::Sending,
admin: &super::admin::Admin, admin: &super::admin::Admin,
account_data: &super::account_data::AccountData, account_data: &super::account_data::AccountData,
@ -983,7 +983,7 @@ impl Rooms {
member_content: member::MemberEventContent, member_content: member::MemberEventContent,
sender: &UserId, sender: &UserId,
account_data: &super::account_data::AccountData, account_data: &super::account_data::AccountData,
globals: &super::globals::Globals, globals: &super::globals::Globals<'_>,
) -> Result<()> { ) -> Result<()> {
let membership = member_content.membership; let membership = member_content.membership;
@ -1150,7 +1150,7 @@ impl Rooms {
&self, &self,
alias: &RoomAliasId, alias: &RoomAliasId,
room_id: Option<&RoomId>, room_id: Option<&RoomId>,
globals: &super::globals::Globals, globals: &super::globals::Globals<'_>,
) -> Result<()> { ) -> Result<()> {
if let Some(room_id) = room_id { if let Some(room_id) = room_id {
// New alias // New alias

18
src/database/rooms/edus.rs

@ -32,7 +32,7 @@ impl RoomEdus {
user_id: &UserId, user_id: &UserId,
room_id: &RoomId, room_id: &RoomId,
event: EduEvent, event: EduEvent,
globals: &super::super::globals::Globals, globals: &super::super::globals::Globals<'_>,
) -> Result<()> { ) -> Result<()> {
let mut prefix = room_id.to_string().as_bytes().to_vec(); let mut prefix = room_id.to_string().as_bytes().to_vec();
prefix.push(0xff); prefix.push(0xff);
@ -99,7 +99,7 @@ impl RoomEdus {
room_id: &RoomId, room_id: &RoomId,
user_id: &UserId, user_id: &UserId,
count: u64, count: u64,
globals: &super::super::globals::Globals, globals: &super::super::globals::Globals<'_>,
) -> Result<()> { ) -> Result<()> {
let mut key = room_id.to_string().as_bytes().to_vec(); let mut key = room_id.to_string().as_bytes().to_vec();
key.push(0xff); key.push(0xff);
@ -151,7 +151,7 @@ impl RoomEdus {
user_id: &UserId, user_id: &UserId,
room_id: &RoomId, room_id: &RoomId,
timeout: u64, timeout: u64,
globals: &super::super::globals::Globals, globals: &super::super::globals::Globals<'_>,
) -> Result<()> { ) -> Result<()> {
let mut prefix = room_id.to_string().as_bytes().to_vec(); let mut prefix = room_id.to_string().as_bytes().to_vec();
prefix.push(0xff); prefix.push(0xff);
@ -177,7 +177,7 @@ impl RoomEdus {
&self, &self,
user_id: &UserId, user_id: &UserId,
room_id: &RoomId, room_id: &RoomId,
globals: &super::super::globals::Globals, globals: &super::super::globals::Globals<'_>,
) -> Result<()> { ) -> Result<()> {
let mut prefix = room_id.to_string().as_bytes().to_vec(); let mut prefix = room_id.to_string().as_bytes().to_vec();
prefix.push(0xff); prefix.push(0xff);
@ -211,7 +211,7 @@ impl RoomEdus {
fn typings_maintain( fn typings_maintain(
&self, &self,
room_id: &RoomId, room_id: &RoomId,
globals: &super::super::globals::Globals, globals: &super::super::globals::Globals<'_>,
) -> Result<()> { ) -> Result<()> {
let mut prefix = room_id.to_string().as_bytes().to_vec(); let mut prefix = room_id.to_string().as_bytes().to_vec();
prefix.push(0xff); prefix.push(0xff);
@ -259,7 +259,7 @@ impl RoomEdus {
pub fn last_typing_update( pub fn last_typing_update(
&self, &self,
room_id: &RoomId, room_id: &RoomId,
globals: &super::super::globals::Globals, globals: &super::super::globals::Globals<'_>,
) -> Result<u64> { ) -> Result<u64> {
self.typings_maintain(room_id, globals)?; self.typings_maintain(room_id, globals)?;
@ -313,7 +313,7 @@ impl RoomEdus {
user_id: &UserId, user_id: &UserId,
room_id: &RoomId, room_id: &RoomId,
presence: ruma::events::presence::PresenceEvent, presence: ruma::events::presence::PresenceEvent,
globals: &super::super::globals::Globals, globals: &super::super::globals::Globals<'_>,
) -> Result<()> { ) -> Result<()> {
// TODO: Remove old entry? Or maybe just wipe completely from time to time? // TODO: Remove old entry? Or maybe just wipe completely from time to time?
@ -364,7 +364,7 @@ impl RoomEdus {
pub fn presence_maintain( pub fn presence_maintain(
&self, &self,
rooms: &super::Rooms, rooms: &super::Rooms,
globals: &super::super::globals::Globals, globals: &super::super::globals::Globals<'_>,
) -> Result<()> { ) -> Result<()> {
let current_timestamp = utils::millis_since_unix_epoch(); let current_timestamp = utils::millis_since_unix_epoch();
@ -431,7 +431,7 @@ impl RoomEdus {
room_id: &RoomId, room_id: &RoomId,
since: u64, since: u64,
rooms: &super::Rooms, rooms: &super::Rooms,
globals: &super::super::globals::Globals, globals: &super::super::globals::Globals<'_>,
) -> Result<HashMap<UserId, PresenceEvent>> { ) -> Result<HashMap<UserId, PresenceEvent>> {
self.presence_maintain(rooms, globals)?; self.presence_maintain(rooms, globals)?;

4
src/database/sending.rs

@ -16,7 +16,7 @@ pub struct Sending {
} }
impl Sending { impl Sending {
pub fn start_handler(&self, globals: &super::globals::Globals, rooms: &super::rooms::Rooms) { pub fn start_handler(&self, globals: &super::globals::Globals<'static>, rooms: &super::rooms::Rooms) {
let servernamepduids = self.servernamepduids.clone(); let servernamepduids = self.servernamepduids.clone();
let servercurrentpdus = self.servercurrentpdus.clone(); let servercurrentpdus = self.servercurrentpdus.clone();
let rooms = rooms.clone(); let rooms = rooms.clone();
@ -174,7 +174,7 @@ impl Sending {
async fn handle_event( async fn handle_event(
server: Box<ServerName>, server: Box<ServerName>,
pdu_ids: Vec<IVec>, pdu_ids: Vec<IVec>,
globals: &super::globals::Globals, globals: &super::globals::Globals<'static>,
rooms: &super::rooms::Rooms, rooms: &super::rooms::Rooms,
) -> std::result::Result< ) -> std::result::Result<
(Box<ServerName>, send_transaction_message::v1::Response), (Box<ServerName>, send_transaction_message::v1::Response),

2
src/database/uiaa.rs

@ -30,7 +30,7 @@ impl Uiaa {
auth: &IncomingAuthData, auth: &IncomingAuthData,
uiaainfo: &UiaaInfo, uiaainfo: &UiaaInfo,
users: &super::users::Users, users: &super::users::Users,
globals: &super::globals::Globals, globals: &super::globals::Globals<'_>,
) -> Result<(bool, UiaaInfo)> { ) -> Result<(bool, UiaaInfo)> {
if let IncomingAuthData::DirectRequest { if let IncomingAuthData::DirectRequest {
kind, kind,

14
src/database/users.rs

@ -278,7 +278,7 @@ impl Users {
device_id: &DeviceId, device_id: &DeviceId,
one_time_key_key: &DeviceKeyId, one_time_key_key: &DeviceKeyId,
one_time_key_value: &OneTimeKey, one_time_key_value: &OneTimeKey,
globals: &super::globals::Globals, globals: &super::globals::Globals<'_>,
) -> Result<()> { ) -> Result<()> {
let mut key = user_id.to_string().as_bytes().to_vec(); let mut key = user_id.to_string().as_bytes().to_vec();
key.push(0xff); key.push(0xff);
@ -327,7 +327,7 @@ impl Users {
user_id: &UserId, user_id: &UserId,
device_id: &DeviceId, device_id: &DeviceId,
key_algorithm: &DeviceKeyAlgorithm, key_algorithm: &DeviceKeyAlgorithm,
globals: &super::globals::Globals, globals: &super::globals::Globals<'_>,
) -> Result<Option<(DeviceKeyId, OneTimeKey)>> { ) -> Result<Option<(DeviceKeyId, OneTimeKey)>> {
let mut prefix = user_id.to_string().as_bytes().to_vec(); let mut prefix = user_id.to_string().as_bytes().to_vec();
prefix.push(0xff); prefix.push(0xff);
@ -403,7 +403,7 @@ impl Users {
device_id: &DeviceId, device_id: &DeviceId,
device_keys: &IncomingDeviceKeys, device_keys: &IncomingDeviceKeys,
rooms: &super::rooms::Rooms, rooms: &super::rooms::Rooms,
globals: &super::globals::Globals, globals: &super::globals::Globals<'_>,
) -> Result<()> { ) -> Result<()> {
let mut userdeviceid = user_id.to_string().as_bytes().to_vec(); let mut userdeviceid = user_id.to_string().as_bytes().to_vec();
userdeviceid.push(0xff); userdeviceid.push(0xff);
@ -426,7 +426,7 @@ impl Users {
self_signing_key: &Option<CrossSigningKey>, self_signing_key: &Option<CrossSigningKey>,
user_signing_key: &Option<CrossSigningKey>, user_signing_key: &Option<CrossSigningKey>,
rooms: &super::rooms::Rooms, rooms: &super::rooms::Rooms,
globals: &super::globals::Globals, globals: &super::globals::Globals<'_>,
) -> Result<()> { ) -> Result<()> {
// TODO: Check signatures // TODO: Check signatures
@ -526,7 +526,7 @@ impl Users {
signature: (String, String), signature: (String, String),
sender_id: &UserId, sender_id: &UserId,
rooms: &super::rooms::Rooms, rooms: &super::rooms::Rooms,
globals: &super::globals::Globals, globals: &super::globals::Globals<'_>,
) -> Result<()> { ) -> Result<()> {
let mut key = target_id.to_string().as_bytes().to_vec(); let mut key = target_id.to_string().as_bytes().to_vec();
key.push(0xff); key.push(0xff);
@ -600,7 +600,7 @@ impl Users {
&self, &self,
user_id: &UserId, user_id: &UserId,
rooms: &super::rooms::Rooms, rooms: &super::rooms::Rooms,
globals: &super::globals::Globals, globals: &super::globals::Globals<'_>,
) -> Result<()> { ) -> Result<()> {
let count = globals.next_count()?.to_be_bytes(); let count = globals.next_count()?.to_be_bytes();
for room_id in rooms.rooms_joined(&user_id).filter_map(|r| r.ok()) { for room_id in rooms.rooms_joined(&user_id).filter_map(|r| r.ok()) {
@ -717,7 +717,7 @@ impl Users {
target_device_id: &DeviceId, target_device_id: &DeviceId,
event_type: &EventType, event_type: &EventType,
content: serde_json::Value, content: serde_json::Value,
globals: &super::globals::Globals, globals: &super::globals::Globals<'_>,
) -> Result<()> { ) -> Result<()> {
let mut key = target_user_id.to_string().as_bytes().to_vec(); let mut key = target_user_id.to_string().as_bytes().to_vec();
key.push(0xff); key.push(0xff);

2
src/ruma_wrapper.rs

@ -57,7 +57,7 @@ where
Box::pin(async move { Box::pin(async move {
let data = rocket::try_outcome!(outcome.owned()); let data = rocket::try_outcome!(outcome.owned());
let db = request let db = request
.guard::<State<'_, crate::Database>>() .guard::<State<'_, crate::Database<'_>>>()
.await .await
.expect("database was loaded"); .expect("database was loaded");

22
src/server_server.rs

@ -28,7 +28,7 @@ use std::{
use trust_dns_resolver::AsyncResolver; use trust_dns_resolver::AsyncResolver;
pub async fn request_well_known( pub async fn request_well_known(
globals: &crate::database::globals::Globals, globals: &crate::database::globals::Globals<'static>,
destination: &str, destination: &str,
) -> Option<String> { ) -> Option<String> {
let body: serde_json::Value = serde_json::from_str( let body: serde_json::Value = serde_json::from_str(
@ -50,7 +50,7 @@ pub async fn request_well_known(
} }
pub async fn send_request<T: OutgoingRequest>( pub async fn send_request<T: OutgoingRequest>(
globals: &crate::database::globals::Globals, globals: &crate::database::globals::Globals<'static>,
destination: Box<ServerName>, destination: Box<ServerName>,
request: T, request: T,
) -> Result<T::IncomingResponse> ) -> Result<T::IncomingResponse>
@ -211,7 +211,7 @@ where
} }
#[cfg_attr(feature = "conduit_bin", get("/_matrix/federation/v1/version"))] #[cfg_attr(feature = "conduit_bin", get("/_matrix/federation/v1/version"))]
pub fn get_server_version(db: State<'_, Database>) -> ConduitResult<get_server_version::Response> { pub fn get_server_version(db: State<'_, Database<'_>>) -> ConduitResult<get_server_version::Response> {
if !db.globals.federation_enabled() { if !db.globals.federation_enabled() {
return Err(Error::BadConfig("Federation is disabled.")); return Err(Error::BadConfig("Federation is disabled."));
} }
@ -226,7 +226,7 @@ pub fn get_server_version(db: State<'_, Database>) -> ConduitResult<get_server_v
} }
#[cfg_attr(feature = "conduit_bin", get("/_matrix/key/v2/server"))] #[cfg_attr(feature = "conduit_bin", get("/_matrix/key/v2/server"))]
pub fn get_server_keys(db: State<'_, Database>) -> Json<String> { pub fn get_server_keys(db: State<'_, Database<'_>>) -> Json<String> {
if !db.globals.federation_enabled() { if !db.globals.federation_enabled() {
// TODO: Use proper types // TODO: Use proper types
return Json("Federation is disabled.".to_owned()); return Json("Federation is disabled.".to_owned());
@ -263,7 +263,7 @@ pub fn get_server_keys(db: State<'_, Database>) -> Json<String> {
} }
#[cfg_attr(feature = "conduit_bin", get("/_matrix/key/v2/server/<_>"))] #[cfg_attr(feature = "conduit_bin", get("/_matrix/key/v2/server/<_>"))]
pub fn get_server_keys_deprecated(db: State<'_, Database>) -> Json<String> { pub fn get_server_keys_deprecated(db: State<'_, Database<'_>>) -> Json<String> {
get_server_keys(db) get_server_keys(db)
} }
@ -272,7 +272,7 @@ pub fn get_server_keys_deprecated(db: State<'_, Database>) -> Json<String> {
post("/_matrix/federation/v1/publicRooms", data = "<body>") post("/_matrix/federation/v1/publicRooms", data = "<body>")
)] )]
pub async fn get_public_rooms_filtered_route( pub async fn get_public_rooms_filtered_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_public_rooms_filtered::v1::Request<'_>>, body: Ruma<get_public_rooms_filtered::v1::Request<'_>>,
) -> ConduitResult<get_public_rooms_filtered::v1::Response> { ) -> ConduitResult<get_public_rooms_filtered::v1::Response> {
if !db.globals.federation_enabled() { if !db.globals.federation_enabled() {
@ -319,7 +319,7 @@ pub async fn get_public_rooms_filtered_route(
get("/_matrix/federation/v1/publicRooms", data = "<body>") get("/_matrix/federation/v1/publicRooms", data = "<body>")
)] )]
pub async fn get_public_rooms_route( pub async fn get_public_rooms_route(
db: State<'_, Database>, db: State<'_, Database<'_>>,
body: Ruma<get_public_rooms::v1::Request<'_>>, body: Ruma<get_public_rooms::v1::Request<'_>>,
) -> ConduitResult<get_public_rooms::v1::Response> { ) -> ConduitResult<get_public_rooms::v1::Response> {
if !db.globals.federation_enabled() { if !db.globals.federation_enabled() {
@ -366,7 +366,7 @@ pub async fn get_public_rooms_route(
put("/_matrix/federation/v1/send/<_>", data = "<body>") put("/_matrix/federation/v1/send/<_>", data = "<body>")
)] )]
pub fn send_transaction_message_route<'a>( pub fn send_transaction_message_route<'a>(
db: State<'a, Database>, db: State<'a, Database<'_>>,
body: Ruma<send_transaction_message::v1::Request<'_>>, body: Ruma<send_transaction_message::v1::Request<'_>>,
) -> ConduitResult<send_transaction_message::v1::Response> { ) -> ConduitResult<send_transaction_message::v1::Response> {
if !db.globals.federation_enabled() { if !db.globals.federation_enabled() {
@ -419,7 +419,7 @@ pub fn send_transaction_message_route<'a>(
post("/_matrix/federation/v1/get_missing_events/<_>", data = "<body>") post("/_matrix/federation/v1/get_missing_events/<_>", data = "<body>")
)] )]
pub fn get_missing_events_route<'a>( pub fn get_missing_events_route<'a>(
db: State<'a, Database>, db: State<'a, Database<'_>>,
body: Ruma<get_missing_events::v1::Request<'_>>, body: Ruma<get_missing_events::v1::Request<'_>>,
) -> ConduitResult<get_missing_events::v1::Response> { ) -> ConduitResult<get_missing_events::v1::Response> {
if !db.globals.federation_enabled() { if !db.globals.federation_enabled() {
@ -464,7 +464,7 @@ pub fn get_missing_events_route<'a>(
get("/_matrix/federation/v1/query/profile", data = "<body>") get("/_matrix/federation/v1/query/profile", data = "<body>")
)] )]
pub fn get_profile_information_route<'a>( pub fn get_profile_information_route<'a>(
db: State<'a, Database>, db: State<'a, Database<'_>>,
body: Ruma<get_profile_information::v1::Request<'_>>, body: Ruma<get_profile_information::v1::Request<'_>>,
) -> ConduitResult<get_profile_information::v1::Response> { ) -> ConduitResult<get_profile_information::v1::Response> {
if !db.globals.federation_enabled() { if !db.globals.federation_enabled() {
@ -496,7 +496,7 @@ pub fn get_profile_information_route<'a>(
get("/_matrix/federation/v2/invite/<_>/<_>", data = "<body>") get("/_matrix/federation/v2/invite/<_>/<_>", data = "<body>")
)] )]
pub fn get_user_devices_route<'a>( pub fn get_user_devices_route<'a>(
db: State<'a, Database>, db: State<'a, Database<'_>>,
body: Ruma<membership::v1::Request<'_>>, body: Ruma<membership::v1::Request<'_>>,
) -> ConduitResult<get_profile_information::v1::Response> { ) -> ConduitResult<get_profile_information::v1::Response> {
if !db.globals.federation_enabled() { if !db.globals.federation_enabled() {

Loading…
Cancel
Save