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. 74
      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" @@ -21,6 +21,15 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
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]]
name = "ansi_term"
version = "0.12.1"
@ -216,6 +225,7 @@ dependencies = [ @@ -216,6 +225,7 @@ dependencies = [
"http",
"image",
"js_int",
"jsonwebtoken",
"log",
"rand",
"reqwest",
@ -844,6 +854,20 @@ dependencies = [ @@ -844,6 +854,20 @@ dependencies = [
"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]]
name = "kernel32-sys"
version = "0.2.2"
@ -1053,6 +1077,17 @@ dependencies = [ @@ -1053,6 +1077,17 @@ dependencies = [
"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]]
name = "num-integer"
version = "0.1.43"
@ -1206,6 +1241,17 @@ dependencies = [ @@ -1206,6 +1241,17 @@ dependencies = [
"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]]
name = "percent-encoding"
version = "2.1.0"
@ -1409,7 +1455,10 @@ version = "1.4.1" @@ -1409,7 +1455,10 @@ version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8963b85b8ce3074fecffde43b4b0dded83ce2f367dc8d363afc56679f3ee820b"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
"thread_local",
]
[[package]]
@ -1918,6 +1967,17 @@ dependencies = [ @@ -1918,6 +1967,17 @@ dependencies = [
"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]]
name = "slab"
version = "0.4.2"
@ -2067,9 +2127,9 @@ dependencies = [ @@ -2067,9 +2127,9 @@ dependencies = [
[[package]]
name = "syn"
version = "1.0.44"
version = "1.0.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e03e57e4fcbfe7749842d53e24ccb9aa12b7252dbe5e91d2acad31834c8b8fdd"
checksum = "ea9c5432ff16d6152371f808fb5a871cd67368171b09bb21b43df8e4a47a3556"
dependencies = [
"proc-macro2",
"quote",

2
Cargo.toml

@ -59,6 +59,8 @@ ring = "0.16.15" @@ -59,6 +59,8 @@ ring = "0.16.15"
# Used when querying the SRV record of other servers
trust-dns-resolver = "0.19.5"
jsonwebtoken = "7.2.0"
[features]
default = ["conduit_bin"]
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; @@ -43,7 +43,7 @@ const GUEST_NAME_LENGTH: usize = 10;
get("/_matrix/client/r0/register/available", data = "<body>")
)]
pub async fn get_register_available_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_username_availability::Request<'_>>,
) -> ConduitResult<get_username_availability::Response> {
// Validate user id
@ -85,7 +85,7 @@ pub async fn get_register_available_route( @@ -85,7 +85,7 @@ pub async fn get_register_available_route(
post("/_matrix/client/r0/register", data = "<body>")
)]
pub async fn register_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<register::Request<'_>>,
) -> ConduitResult<register::Response> {
if db.globals.registration_disabled() {
@ -532,7 +532,7 @@ pub async fn register_route( @@ -532,7 +532,7 @@ pub async fn register_route(
post("/_matrix/client/r0/account/password", data = "<body>")
)]
pub async fn change_password_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<change_password::Request<'_>>,
) -> ConduitResult<change_password::Response> {
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:: @@ -616,7 +616,7 @@ pub async fn whoami_route(body: Ruma<whoami::Request>) -> ConduitResult<whoami::
post("/_matrix/client/r0/account/deactivate", data = "<body>")
)]
pub async fn deactivate_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<deactivate::Request<'_>>,
) -> ConduitResult<deactivate::Response> {
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}; @@ -19,7 +19,7 @@ use rocket::{delete, get, put};
put("/_matrix/client/r0/directory/room/<_>", data = "<body>")
)]
pub async fn create_alias_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<create_alias::Request<'_>>,
) -> ConduitResult<create_alias::Response> {
if db.rooms.id_from_alias(&body.room_alias)?.is_some() {
@ -39,7 +39,7 @@ pub async fn create_alias_route( @@ -39,7 +39,7 @@ pub async fn create_alias_route(
delete("/_matrix/client/r0/directory/room/<_>", data = "<body>")
)]
pub async fn delete_alias_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<delete_alias::Request<'_>>,
) -> ConduitResult<delete_alias::Response> {
db.rooms.set_alias(&body.room_alias, None, &db.globals)?;
@ -54,14 +54,14 @@ pub async fn delete_alias_route( @@ -54,14 +54,14 @@ pub async fn delete_alias_route(
get("/_matrix/client/r0/directory/room/<_>", data = "<body>")
)]
pub async fn get_alias_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_alias::Request<'_>>,
) -> ConduitResult<get_alias::Response> {
get_alias_helper(&db, &body.room_alias).await
}
pub async fn get_alias_helper(
db: &Database,
db: &Database<'static>,
room_alias: &RoomAliasId,
) -> ConduitResult<get_alias::Response> {
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}; @@ -18,7 +18,7 @@ use rocket::{delete, get, post, put};
post("/_matrix/client/unstable/room_keys/version", data = "<body>")
)]
pub async fn create_backup_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<create_backup::Request>,
) -> ConduitResult<create_backup::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -36,7 +36,7 @@ pub async fn create_backup_route( @@ -36,7 +36,7 @@ pub async fn create_backup_route(
put("/_matrix/client/unstable/room_keys/version/<_>", data = "<body>")
)]
pub async fn update_backup_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<update_backup::Request<'_>>,
) -> ConduitResult<update_backup::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -53,7 +53,7 @@ pub async fn update_backup_route( @@ -53,7 +53,7 @@ pub async fn update_backup_route(
get("/_matrix/client/unstable/room_keys/version", data = "<body>")
)]
pub async fn get_latest_backup_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_latest_backup::Request>,
) -> ConduitResult<get_latest_backup::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -80,7 +80,7 @@ pub async fn get_latest_backup_route( @@ -80,7 +80,7 @@ pub async fn get_latest_backup_route(
get("/_matrix/client/unstable/room_keys/version/<_>", data = "<body>")
)]
pub async fn get_backup_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_backup::Request<'_>>,
) -> ConduitResult<get_backup::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -106,7 +106,7 @@ pub async fn get_backup_route( @@ -106,7 +106,7 @@ pub async fn get_backup_route(
delete("/_matrix/client/unstable/room_keys/version/<_>", data = "<body>")
)]
pub async fn delete_backup_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<delete_backup::Request>,
) -> ConduitResult<delete_backup::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -124,7 +124,7 @@ pub async fn delete_backup_route( @@ -124,7 +124,7 @@ pub async fn delete_backup_route(
put("/_matrix/client/unstable/room_keys/keys", data = "<body>")
)]
pub async fn add_backup_keys_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<add_backup_keys::Request<'_>>,
) -> ConduitResult<add_backup_keys::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -157,7 +157,7 @@ pub async fn add_backup_keys_route( @@ -157,7 +157,7 @@ pub async fn add_backup_keys_route(
put("/_matrix/client/unstable/room_keys/keys/<_>", data = "<body>")
)]
pub async fn add_backup_key_sessions_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<add_backup_key_sessions::Request>,
) -> ConduitResult<add_backup_key_sessions::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -188,7 +188,7 @@ pub async fn add_backup_key_sessions_route( @@ -188,7 +188,7 @@ pub async fn add_backup_key_sessions_route(
put("/_matrix/client/unstable/room_keys/keys/<_>/<_>", data = "<body>")
)]
pub async fn add_backup_key_session_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<add_backup_key_session::Request>,
) -> ConduitResult<add_backup_key_session::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -216,7 +216,7 @@ pub async fn add_backup_key_session_route( @@ -216,7 +216,7 @@ pub async fn add_backup_key_session_route(
get("/_matrix/client/unstable/room_keys/keys", data = "<body>")
)]
pub async fn get_backup_keys_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_backup_keys::Request<'_>>,
) -> ConduitResult<get_backup_keys::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -231,7 +231,7 @@ pub async fn get_backup_keys_route( @@ -231,7 +231,7 @@ pub async fn get_backup_keys_route(
get("/_matrix/client/unstable/room_keys/keys/<_>", data = "<body>")
)]
pub async fn get_backup_key_sessions_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_backup_key_sessions::Request>,
) -> ConduitResult<get_backup_key_sessions::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -248,7 +248,7 @@ pub async fn get_backup_key_sessions_route( @@ -248,7 +248,7 @@ pub async fn get_backup_key_sessions_route(
get("/_matrix/client/unstable/room_keys/keys/<_>/<_>", data = "<body>")
)]
pub async fn get_backup_key_session_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_backup_key_session::Request>,
) -> ConduitResult<get_backup_key_session::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -265,7 +265,7 @@ pub async fn get_backup_key_session_route( @@ -265,7 +265,7 @@ pub async fn get_backup_key_session_route(
delete("/_matrix/client/unstable/room_keys/keys", data = "<body>")
)]
pub async fn delete_backup_keys_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<delete_backup_keys::Request>,
) -> ConduitResult<delete_backup_keys::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -287,7 +287,7 @@ pub async fn delete_backup_keys_route( @@ -287,7 +287,7 @@ pub async fn delete_backup_keys_route(
delete("/_matrix/client/unstable/room_keys/keys/<_>", data = "<body>")
)]
pub async fn delete_backup_key_sessions_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<delete_backup_key_sessions::Request>,
) -> ConduitResult<delete_backup_key_sessions::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -309,7 +309,7 @@ pub async fn delete_backup_key_sessions_route( @@ -309,7 +309,7 @@ pub async fn delete_backup_key_sessions_route(
delete("/_matrix/client/unstable/room_keys/keys/<_>/<_>", data = "<body>")
)]
pub async fn delete_backup_key_session_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<delete_backup_key_session::Request>,
) -> ConduitResult<delete_backup_key_session::Response> {
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}; @@ -17,7 +17,7 @@ use rocket::{get, put};
put("/_matrix/client/r0/user/<_>/account_data/<_>", data = "<body>")
)]
pub async fn set_global_account_data_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<set_global_account_data::Request<'_>>,
) -> ConduitResult<set_global_account_data::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -50,7 +50,7 @@ pub async fn set_global_account_data_route( @@ -50,7 +50,7 @@ pub async fn set_global_account_data_route(
get("/_matrix/client/r0/user/<_>/account_data/<_>", data = "<body>")
)]
pub async fn get_global_account_data_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_global_account_data::Request<'_>>,
) -> ConduitResult<get_global_account_data::Response> {
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; @@ -11,7 +11,7 @@ use rocket::get;
get("/_matrix/client/r0/rooms/<_>/context/<_>", data = "<body>")
)]
pub async fn get_context_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_context::Request<'_>>,
) -> ConduitResult<get_context::Response> {
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}; @@ -17,7 +17,7 @@ use rocket::{delete, get, post, put};
get("/_matrix/client/r0/devices", data = "<body>")
)]
pub async fn get_devices_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_devices::Request>,
) -> ConduitResult<get_devices::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -36,7 +36,7 @@ pub async fn get_devices_route( @@ -36,7 +36,7 @@ pub async fn get_devices_route(
get("/_matrix/client/r0/devices/<_>", data = "<body>")
)]
pub async fn get_device_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_device::Request<'_>>,
) -> ConduitResult<get_device::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -54,7 +54,7 @@ pub async fn get_device_route( @@ -54,7 +54,7 @@ pub async fn get_device_route(
put("/_matrix/client/r0/devices/<_>", data = "<body>")
)]
pub async fn update_device_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<update_device::Request<'_>>,
) -> ConduitResult<update_device::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -79,7 +79,7 @@ pub async fn update_device_route( @@ -79,7 +79,7 @@ pub async fn update_device_route(
delete("/_matrix/client/r0/devices/<_>", data = "<body>")
)]
pub async fn delete_device_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<delete_device::Request<'_>>,
) -> ConduitResult<delete_device::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -127,7 +127,7 @@ pub async fn delete_device_route( @@ -127,7 +127,7 @@ pub async fn delete_device_route(
post("/_matrix/client/r0/delete_devices", data = "<body>")
)]
pub async fn delete_devices_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<delete_devices::Request<'_>>,
) -> ConduitResult<delete_devices::Response> {
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}; @@ -32,7 +32,7 @@ use rocket::{get, post, put};
post("/_matrix/client/r0/publicRooms", data = "<body>")
)]
pub async fn get_public_rooms_filtered_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_public_rooms_filtered::Request<'_>>,
) -> ConduitResult<get_public_rooms_filtered::Response> {
get_public_rooms_filtered_helper(
@ -51,7 +51,7 @@ pub async fn get_public_rooms_filtered_route( @@ -51,7 +51,7 @@ pub async fn get_public_rooms_filtered_route(
get("/_matrix/client/r0/publicRooms", data = "<body>")
)]
pub async fn get_public_rooms_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_public_rooms::Request<'_>>,
) -> ConduitResult<get_public_rooms::Response> {
let response = get_public_rooms_filtered_helper(
@ -79,7 +79,7 @@ pub async fn get_public_rooms_route( @@ -79,7 +79,7 @@ pub async fn get_public_rooms_route(
put("/_matrix/client/r0/directory/list/room/<_>", data = "<body>")
)]
pub async fn set_room_visibility_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<set_room_visibility::Request<'_>>,
) -> ConduitResult<set_room_visibility::Response> {
match body.visibility {
@ -97,7 +97,7 @@ pub async fn set_room_visibility_route( @@ -97,7 +97,7 @@ pub async fn set_room_visibility_route(
get("/_matrix/client/r0/directory/list/room/<_>", data = "<body>")
)]
pub async fn get_room_visibility_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_room_visibility::Request<'_>>,
) -> ConduitResult<get_room_visibility::Response> {
Ok(get_room_visibility::Response {
@ -111,7 +111,7 @@ pub async fn get_room_visibility_route( @@ -111,7 +111,7 @@ pub async fn get_room_visibility_route(
}
pub async fn get_public_rooms_filtered_helper(
db: &Database,
db: &Database<'static>,
server: Option<&ServerName>,
limit: Option<js_int::UInt>,
since: Option<&str>,

12
src/client_server/keys.rs

@ -23,7 +23,7 @@ use rocket::{get, post}; @@ -23,7 +23,7 @@ use rocket::{get, post};
post("/_matrix/client/r0/keys/upload", data = "<body>")
)]
pub async fn upload_keys_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<upload_keys::Request<'_>>,
) -> ConduitResult<upload_keys::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -71,7 +71,7 @@ pub async fn upload_keys_route( @@ -71,7 +71,7 @@ pub async fn upload_keys_route(
post("/_matrix/client/r0/keys/query", data = "<body>")
)]
pub async fn get_keys_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_keys::Request<'_>>,
) -> ConduitResult<get_keys::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -151,7 +151,7 @@ pub async fn get_keys_route( @@ -151,7 +151,7 @@ pub async fn get_keys_route(
post("/_matrix/client/r0/keys/claim", data = "<body>")
)]
pub async fn claim_keys_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<claim_keys::Request>,
) -> ConduitResult<claim_keys::Response> {
let mut one_time_keys = BTreeMap::new();
@ -184,7 +184,7 @@ pub async fn claim_keys_route( @@ -184,7 +184,7 @@ pub async fn claim_keys_route(
post("/_matrix/client/unstable/keys/device_signing/upload", data = "<body>")
)]
pub async fn upload_signing_keys_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<upload_signing_keys::Request<'_>>,
) -> ConduitResult<upload_signing_keys::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -241,7 +241,7 @@ pub async fn upload_signing_keys_route( @@ -241,7 +241,7 @@ pub async fn upload_signing_keys_route(
post("/_matrix/client/unstable/keys/signatures/upload", data = "<body>")
)]
pub async fn upload_signatures_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<upload_signatures::Request>,
) -> ConduitResult<upload_signatures::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -301,7 +301,7 @@ pub async fn upload_signatures_route( @@ -301,7 +301,7 @@ pub async fn upload_signatures_route(
get("/_matrix/client/r0/keys/changes", data = "<body>")
)]
pub async fn get_key_changes_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_key_changes::Request<'_>>,
) -> ConduitResult<get_key_changes::Response> {
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; @@ -15,7 +15,7 @@ const MXC_LENGTH: usize = 32;
#[cfg_attr(feature = "conduit_bin", get("/_matrix/media/r0/config"))]
pub async fn get_media_config_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
) -> ConduitResult<get_media_config::Response> {
Ok(get_media_config::Response {
upload_size: db.globals.max_request_size().into(),
@ -28,7 +28,7 @@ pub async fn get_media_config_route( @@ -28,7 +28,7 @@ pub async fn get_media_config_route(
post("/_matrix/media/r0/upload", data = "<body>")
)]
pub async fn create_content_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<create_content::Request<'_>>,
) -> ConduitResult<create_content::Response> {
let mxc = format!(
@ -53,7 +53,7 @@ pub async fn create_content_route( @@ -53,7 +53,7 @@ pub async fn create_content_route(
get("/_matrix/media/r0/download/<_>/<_>", data = "<body>")
)]
pub async fn get_content_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_content::Request<'_>>,
) -> ConduitResult<get_content::Response> {
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);
@ -100,7 +100,7 @@ pub async fn get_content_route( @@ -100,7 +100,7 @@ pub async fn get_content_route(
get("/_matrix/media/r0/thumbnail/<_>/<_>", data = "<body>")
)]
pub async fn get_content_thumbnail_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_content_thumbnail::Request<'_>>,
) -> ConduitResult<get_content_thumbnail::Response> {
let mxc = format!("mxc://{}/{}", body.server_name, body.media_id);

24
src/client_server/membership.rs

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

4
src/client_server/message.rs

@ -18,7 +18,7 @@ use rocket::{get, put}; @@ -18,7 +18,7 @@ use rocket::{get, put};
put("/_matrix/client/r0/rooms/<_>/send/<_>/<_>", data = "<body>")
)]
pub async fn send_message_event_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<send_message_event::Request<'_>>,
) -> ConduitResult<send_message_event::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -88,7 +88,7 @@ pub async fn send_message_event_route( @@ -88,7 +88,7 @@ pub async fn send_message_event_route(
get("/_matrix/client/r0/rooms/<_>/messages", data = "<body>")
)]
pub async fn get_message_events_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_message_events::Request<'_>>,
) -> ConduitResult<get_message_events::Response> {
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; @@ -11,7 +11,7 @@ use rocket::put;
put("/_matrix/client/r0/presence/<_>/status", data = "<body>")
)]
pub async fn set_presence_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<set_presence::Request<'_>>,
) -> ConduitResult<set_presence::Response> {
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; @@ -20,7 +20,7 @@ use std::convert::TryInto;
put("/_matrix/client/r0/profile/<_>/displayname", data = "<body>")
)]
pub async fn set_displayname_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<set_display_name::Request<'_>>,
) -> ConduitResult<set_display_name::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -102,7 +102,7 @@ pub async fn set_displayname_route( @@ -102,7 +102,7 @@ pub async fn set_displayname_route(
get("/_matrix/client/r0/profile/<_>/displayname", data = "<body>")
)]
pub async fn get_displayname_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_display_name::Request<'_>>,
) -> ConduitResult<get_display_name::Response> {
Ok(get_display_name::Response {
@ -116,7 +116,7 @@ pub async fn get_displayname_route( @@ -116,7 +116,7 @@ pub async fn get_displayname_route(
put("/_matrix/client/r0/profile/<_>/avatar_url", data = "<body>")
)]
pub async fn set_avatar_url_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<set_avatar_url::Request<'_>>,
) -> ConduitResult<set_avatar_url::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -198,7 +198,7 @@ pub async fn set_avatar_url_route( @@ -198,7 +198,7 @@ pub async fn set_avatar_url_route(
get("/_matrix/client/r0/profile/<_>/avatar_url", data = "<body>")
)]
pub async fn get_avatar_url_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_avatar_url::Request<'_>>,
) -> ConduitResult<get_avatar_url::Response> {
Ok(get_avatar_url::Response {
@ -212,7 +212,7 @@ pub async fn get_avatar_url_route( @@ -212,7 +212,7 @@ pub async fn get_avatar_url_route(
get("/_matrix/client/r0/profile/<_>", data = "<body>")
)]
pub async fn get_profile_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_profile::Request<'_>>,
) -> ConduitResult<get_profile::Response> {
if !db.users.exists(&body.user_id)? {

8
src/client_server/push.rs

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

2
src/client_server/read_marker.rs

@ -14,7 +14,7 @@ use std::{collections::BTreeMap, time::SystemTime}; @@ -14,7 +14,7 @@ use std::{collections::BTreeMap, time::SystemTime};
post("/_matrix/client/r0/rooms/<_>/read_markers", data = "<body>")
)]
pub async fn set_read_marker_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<set_read_marker::Request<'_>>,
) -> ConduitResult<set_read_marker::Response> {
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; @@ -13,7 +13,7 @@ use rocket::put;
put("/_matrix/client/r0/rooms/<_>/redact/<_>/<_>", data = "<body>")
)]
pub async fn redact_event_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<redact_event::Request<'_>>,
) -> ConduitResult<redact_event::Response> {
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}; @@ -21,7 +21,7 @@ use rocket::{get, post};
post("/_matrix/client/r0/createRoom", data = "<body>")
)]
pub async fn create_room_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<create_room::Request<'_>>,
) -> ConduitResult<create_room::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -333,7 +333,7 @@ pub async fn create_room_route( @@ -333,7 +333,7 @@ pub async fn create_room_route(
get("/_matrix/client/r0/rooms/<_>/event/<_>", data = "<body>")
)]
pub async fn get_room_event_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_room_event::Request<'_>>,
) -> ConduitResult<get_room_event::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -360,7 +360,7 @@ pub async fn get_room_event_route( @@ -360,7 +360,7 @@ pub async fn get_room_event_route(
post("/_matrix/client/r0/rooms/<_room_id>/upgrade", data = "<body>")
)]
pub async fn upgrade_room_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<upgrade_room::Request<'_>>,
_room_id: String,
) -> ConduitResult<upgrade_room::Response> {

2
src/client_server/search.rs

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

74
src/client_server/session.rs

@ -7,6 +7,13 @@ use ruma::{ @@ -7,6 +7,13 @@ use ruma::{
},
UserId,
};
use serde::Deserialize;
#[derive(Debug, Deserialize)]
struct Claims {
sub: String,
exp: usize,
}
#[cfg(feature = "conduit_bin")]
use rocket::{get, post};
@ -35,44 +42,61 @@ pub async fn get_login_types_route() -> ConduitResult<get_login_types::Response> @@ -35,44 +42,61 @@ pub async fn get_login_types_route() -> ConduitResult<get_login_types::Response>
post("/_matrix/client/r0/login", data = "<body>")
)]
pub async fn login_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<login::Request<'_>>,
) -> ConduitResult<login::Response> {
// Validate login method
let user_id =
// TODO: Other login methods
if let (login::IncomingUserInfo::MatrixId(username), login::IncomingLoginInfo::Password { password }) =
(&body.user, &body.login_info)
{
let user_id = UserId::parse_with_server_name(username.to_string(), db.globals.server_name())
.map_err(|_| Error::BadRequest(
ErrorKind::InvalidUsername,
"Username is invalid."
))?;
let hash = db.users.password_hash(&user_id)?
.ok_or(Error::BadRequest(
ErrorKind::Forbidden,
"Wrong username or password."
))?;
let user_id = match &body.login_info {
login::IncomingLoginInfo::Password { password } => {
let username = if let login::IncomingUserInfo::MatrixId(matrix_id) = &body.user {
matrix_id
} else {
return Err(Error::BadRequest(ErrorKind::Forbidden, "Bad login type."));
};
let user_id = UserId::parse_with_server_name(username.to_owned(), db.globals.server_name())
.map_err(|_| {
Error::BadRequest(ErrorKind::InvalidUsername, "Username is invalid.")
})?;
let hash = db.users.password_hash(&user_id)?.ok_or(Error::BadRequest(
ErrorKind::Forbidden,
"Wrong username or password.",
))?;
if hash.is_empty() {
return Err(Error::BadRequest(
ErrorKind::UserDeactivated,
"The user has been deactivated"
"The user has been deactivated",
));
}
let hash_matches =
argon2::verify_encoded(&hash, password.as_bytes()).unwrap_or(false);
let hash_matches = argon2::verify_encoded(&hash, password.as_bytes()).unwrap_or(false);
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
} else {
return Err(Error::BadRequest(ErrorKind::Forbidden, "Bad login type."));
};
}
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 {
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
let device_id = body
@ -116,7 +140,7 @@ pub async fn login_route( @@ -116,7 +140,7 @@ pub async fn login_route(
post("/_matrix/client/r0/logout", data = "<body>")
)]
pub async fn logout_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<logout::Request>,
) -> ConduitResult<logout::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -143,7 +167,7 @@ pub async fn logout_route( @@ -143,7 +167,7 @@ pub async fn logout_route(
post("/_matrix/client/r0/logout/all", data = "<body>")
)]
pub async fn logout_all_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<logout_all::Request>,
) -> ConduitResult<logout_all::Response> {
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}; @@ -24,7 +24,7 @@ use rocket::{get, put};
put("/_matrix/client/r0/rooms/<_>/state/<_>/<_>", data = "<body>")
)]
pub async fn send_state_event_for_key_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<send_state_event_for_key::Request<'_>>,
) -> ConduitResult<send_state_event_for_key::Response> {
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( @@ -57,7 +57,7 @@ pub async fn send_state_event_for_key_route(
put("/_matrix/client/r0/rooms/<_>/state/<_>", data = "<body>")
)]
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<'_>>,
) -> ConduitResult<send_state_event_for_empty_key::Response> {
// This just calls send_state_event_for_key_route
@ -98,7 +98,7 @@ pub async fn send_state_event_for_empty_key_route( @@ -98,7 +98,7 @@ pub async fn send_state_event_for_empty_key_route(
get("/_matrix/client/r0/rooms/<_>/state", data = "<body>")
)]
pub async fn get_state_events_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_state_events::Request>,
) -> ConduitResult<get_state_events::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -143,7 +143,7 @@ pub async fn get_state_events_route( @@ -143,7 +143,7 @@ pub async fn get_state_events_route(
get("/_matrix/client/r0/rooms/<_>/state/<_>/<_>", data = "<body>")
)]
pub async fn get_state_events_for_key_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_state_events_for_key::Request>,
) -> ConduitResult<get_state_events_for_key::Response> {
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( @@ -193,7 +193,7 @@ pub async fn get_state_events_for_key_route(
get("/_matrix/client/r0/rooms/<_>/state/<_>", data = "<body>")
)]
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>,
) -> ConduitResult<get_state_events_for_empty_key::Response> {
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( @@ -239,7 +239,7 @@ pub async fn get_state_events_for_empty_key_route(
}
pub async fn send_state_event_for_key_helper(
db: &Database,
db: &Database<'_>,
sender: &UserId,
content: &AnyStateEventContent,
json: serde_json::Value,

4
src/client_server/sync.rs

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

6
src/client_server/tag.rs

@ -14,7 +14,7 @@ use rocket::{delete, get, put}; @@ -14,7 +14,7 @@ use rocket::{delete, get, put};
put("/_matrix/client/r0/user/<_>/rooms/<_>/tags/<_>", data = "<body>")
)]
pub async fn update_tag_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<create_tag::Request<'_>>,
) -> ConduitResult<create_tag::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -50,7 +50,7 @@ pub async fn update_tag_route( @@ -50,7 +50,7 @@ pub async fn update_tag_route(
delete("/_matrix/client/r0/user/<_>/rooms/<_>/tags/<_>", data = "<body>")
)]
pub async fn delete_tag_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<delete_tag::Request<'_>>,
) -> ConduitResult<delete_tag::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
@ -83,7 +83,7 @@ pub async fn delete_tag_route( @@ -83,7 +83,7 @@ pub async fn delete_tag_route(
get("/_matrix/client/r0/user/<_>/rooms/<_>/tags", data = "<body>")
)]
pub async fn get_tags_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<get_tags::Request<'_>>,
) -> ConduitResult<get_tags::Response> {
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; @@ -13,7 +13,7 @@ use rocket::put;
put("/_matrix/client/r0/sendToDevice/<_>/<_>", data = "<body>")
)]
pub async fn send_event_to_device_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<send_event_to_device::Request<'_>>,
) -> ConduitResult<send_event_to_device::Response> {
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; @@ -11,7 +11,7 @@ use rocket::put;
put("/_matrix/client/r0/rooms/<_>/typing/<_>", data = "<body>")
)]
pub fn create_typing_event_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<create_typing_event::Request<'_>>,
) -> ConduitResult<create_typing_event::Response> {
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; @@ -10,7 +10,7 @@ use rocket::post;
post("/_matrix/client/r0/user_directory/search", data = "<body>")
)]
pub async fn search_users_route(
db: State<'_, Database>,
db: State<'_, Database<'_>>,
body: Ruma<search_users::Request<'_>>,
) -> ConduitResult<search_users::Response> {
let limit = u64::from(body.limit) as usize;

6
src/database.rs

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

2
src/database/account_data.rs

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

2
src/database/admin.rs

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

19
src/database/globals.rs

@ -6,7 +6,7 @@ use std::{convert::TryInto, sync::Arc}; @@ -6,7 +6,7 @@ use std::{convert::TryInto, sync::Arc};
pub const COUNTER: &str = "c";
#[derive(Clone)]
pub struct Globals {
pub struct Globals<'a> {
pub(super) globals: sled::Tree,
keypair: Arc<ruma::signatures::Ed25519KeyPair>,
reqwest_client: reqwest::Client,
@ -15,9 +15,10 @@ pub struct Globals { @@ -15,9 +15,10 @@ pub struct Globals {
registration_disabled: bool,
encryption_disabled: 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> {
let bytes = &*globals
.update_and_fetch("keypair", utils::generate_keypair)?
@ -53,14 +54,19 @@ impl Globals { @@ -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 {
globals,
keypair: Arc::new(keypair),
reqwest_client: reqwest::Client::new(),
server_name: config
.get_str("server_name")
.unwrap_or("localhost")
.to_string()
.map(std::string::ToString::to_string)
.unwrap_or_else(|_| {
std::env::var("SERVER_NAME").unwrap_or_else(|_| "localhost".to_string())
})
.try_into()
.map_err(|_| Error::BadConfig("Invalid server_name."))?,
max_request_size: config
@ -71,6 +77,7 @@ impl Globals { @@ -71,6 +77,7 @@ impl Globals {
registration_disabled: config.get_bool("registration_disabled").unwrap_or(false),
encryption_disabled: config.get_bool("encryption_disabled").unwrap_or(false),
federation_enabled: config.get_bool("federation_enabled").unwrap_or(false),
jwt_decoding_key,
})
}
@ -120,4 +127,8 @@ impl Globals { @@ -120,4 +127,8 @@ impl Globals {
pub fn federation_enabled(&self) -> bool {
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 { @@ -20,7 +20,7 @@ impl KeyBackups {
&self,
user_id: &UserId,
backup_metadata: &BackupAlgorithm,
globals: &super::globals::Globals,
globals: &super::globals::Globals<'_>,
) -> Result<String> {
let version = globals.next_count()?.to_string();
@ -65,7 +65,7 @@ impl KeyBackups { @@ -65,7 +65,7 @@ impl KeyBackups {
user_id: &UserId,
version: &str,
backup_metadata: &BackupAlgorithm,
globals: &super::globals::Globals,
globals: &super::globals::Globals<'_>,
) -> Result<String> {
let mut key = user_id.to_string().as_bytes().to_vec();
key.push(0xff);
@ -130,7 +130,7 @@ impl KeyBackups { @@ -130,7 +130,7 @@ impl KeyBackups {
room_id: &RoomId,
session_id: &str,
key_data: &KeyData,
globals: &super::globals::Globals,
globals: &super::globals::Globals<'_>,
) -> Result<()> {
let mut key = user_id.to_string().as_bytes().to_vec();
key.push(0xff);

8
src/database/rooms.rs

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

18
src/database/rooms/edus.rs

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

4
src/database/sending.rs

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

2
src/database/uiaa.rs

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

14
src/database/users.rs

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

2
src/ruma_wrapper.rs

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

22
src/server_server.rs

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

Loading…
Cancel
Save