Merge pull request 'Timo's Conditionally emit rocket::http_verb attr macros if lib/bin' (#157) from timo-make-lib into master
Reviewed-on: https://git.koesters.xyz/timo/conduit/pulls/157next
commit
c4260bde81
|
@ -261,7 +261,6 @@ checksum = "0dbbb57365263e881e805dc77d94697c9118fd94d8da011240555aa7b23445bd"
|
||||||
name = "conduit"
|
name = "conduit"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.12.3",
|
|
||||||
"directories",
|
"directories",
|
||||||
"http",
|
"http",
|
||||||
"image",
|
"image",
|
||||||
|
@ -276,7 +275,6 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sled",
|
"sled",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
44
Cargo.toml
44
Cargo.toml
|
@ -12,19 +12,31 @@ edition = "2018"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rocket = { git = "https://github.com/SergioBenitez/Rocket.git", rev = "8d779caa22c63b15a6c3ceb75d8f6d4971b2eb67", features = ["tls"] }
|
# TODO: This can become optional as soon as proper configs are supported
|
||||||
http = "0.2.1"
|
rocket = { git = "https://github.com/SergioBenitez/Rocket.git", rev = "8d779caa22c63b15a6c3ceb75d8f6d4971b2eb67", features = ["tls"], optional = false } # Used to handle requests
|
||||||
log = "0.4.8"
|
ruma = { git = "https://github.com/ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"], rev = "e047c647ddcb368e7eb1e05ae8823a9494273457" } # Used for matrix spec type definitions and helpers
|
||||||
sled = "0.32.0"
|
sled = "0.32.0" # Used for storing data permanently
|
||||||
directories = "2.0.2"
|
log = "0.4.8" # Used for emitting log entries
|
||||||
js_int = "0.1.5"
|
http = "0.2.1" # Used for rocket<->ruma conversions
|
||||||
serde_json = { version = "1.0.53", features = ["raw_value"] }
|
directories = "2.0.2" # Used to find data directory for default db path
|
||||||
serde = "1.0.111"
|
js_int = "0.1.5" # Used for number types for ruma
|
||||||
tokio = { version = "0.2.21", features = ["macros"] }
|
serde_json = { version = "1.0.53", features = ["raw_value"] } # Used for ruma wrapper
|
||||||
rand = "0.7.3"
|
serde = "1.0.111" # Used for pdu definition
|
||||||
rust-argon2 = "0.8.2"
|
rand = "0.7.3" # Used for secure identifiers
|
||||||
reqwest = "0.10.6"
|
rust-argon2 = "0.8.2" # Used to hash passwords
|
||||||
base64 = "0.12.1"
|
reqwest = "0.10.6" # Used to send requests
|
||||||
thiserror = "1.0.19"
|
thiserror = "1.0.19" # Used for conduit::Error type
|
||||||
image = { version = "0.23.4", default-features = false, features = ["jpeg", "png", "gif"] }
|
image = { version = "0.23.4", default-features = false, features = ["jpeg", "png", "gif"] } # Used to generate thumbnails for images
|
||||||
ruma = { git = "https://github.com/ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"], rev = "e047c647ddcb368e7eb1e05ae8823a9494273457" }
|
|
||||||
|
[features]
|
||||||
|
default = ["conduit_bin"]
|
||||||
|
conduit_bin = [] # TODO: add rocket to this when it is optional
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "conduit"
|
||||||
|
path = "src/main.rs"
|
||||||
|
required-features = ["conduit_bin"]
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "conduit"
|
||||||
|
path = "src/lib.rs"
|
||||||
|
|
|
@ -7,7 +7,12 @@ use std::{
|
||||||
use crate::{utils, ConduitResult, Database, Error, Ruma};
|
use crate::{utils, ConduitResult, Database, Error, Ruma};
|
||||||
use keys::{upload_signatures, upload_signing_keys};
|
use keys::{upload_signatures, upload_signing_keys};
|
||||||
use log::warn;
|
use log::warn;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "conduit_bin"))]
|
||||||
|
use super::State;
|
||||||
|
#[cfg(feature = "conduit_bin")]
|
||||||
use rocket::{delete, get, options, post, put, State};
|
use rocket::{delete, get, options, post, put, State};
|
||||||
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
api::client::{
|
api::client::{
|
||||||
error::ErrorKind,
|
error::ErrorKind,
|
||||||
|
@ -77,7 +82,7 @@ const TOKEN_LENGTH: usize = 256;
|
||||||
const MXC_LENGTH: usize = 256;
|
const MXC_LENGTH: usize = 256;
|
||||||
const SESSION_ID_LENGTH: usize = 256;
|
const SESSION_ID_LENGTH: usize = 256;
|
||||||
|
|
||||||
#[get("/_matrix/client/versions")]
|
#[cfg_attr(feature = "conduit_bin", get("/_matrix/client/versions"))]
|
||||||
pub fn get_supported_versions_route() -> ConduitResult<get_supported_versions::Response> {
|
pub fn get_supported_versions_route() -> ConduitResult<get_supported_versions::Response> {
|
||||||
let mut unstable_features = BTreeMap::new();
|
let mut unstable_features = BTreeMap::new();
|
||||||
|
|
||||||
|
@ -90,7 +95,10 @@ pub fn get_supported_versions_route() -> ConduitResult<get_supported_versions::R
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/register/available", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/register/available", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn get_register_available_route(
|
pub fn get_register_available_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<get_username_availability::Request>,
|
body: Ruma<get_username_availability::Request>,
|
||||||
|
@ -120,7 +128,10 @@ pub fn get_register_available_route(
|
||||||
Ok(get_username_availability::Response { available: true }.into())
|
Ok(get_username_availability::Response { available: true }.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/register", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/register", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn register_route(
|
pub fn register_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<register::Request>,
|
body: Ruma<register::Request>,
|
||||||
|
@ -223,7 +234,7 @@ pub fn register_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/login")]
|
#[cfg_attr(feature = "conduit_bin", get("/_matrix/client/r0/login"))]
|
||||||
pub fn get_login_route() -> ConduitResult<get_login_types::Response> {
|
pub fn get_login_route() -> ConduitResult<get_login_types::Response> {
|
||||||
Ok(get_login_types::Response {
|
Ok(get_login_types::Response {
|
||||||
flows: vec![get_login_types::LoginType::Password],
|
flows: vec![get_login_types::LoginType::Password],
|
||||||
|
@ -231,7 +242,10 @@ pub fn get_login_route() -> ConduitResult<get_login_types::Response> {
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/login", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/login", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn login_route(
|
pub fn login_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<login::Request>,
|
body: Ruma<login::Request>,
|
||||||
|
@ -289,7 +303,10 @@ pub fn login_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/logout", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/logout", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn logout_route(
|
pub fn logout_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<logout::Request>,
|
body: Ruma<logout::Request>,
|
||||||
|
@ -302,7 +319,10 @@ pub fn logout_route(
|
||||||
Ok(logout::Response.into())
|
Ok(logout::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/logout/all", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/logout/all", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn logout_all_route(
|
pub fn logout_all_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<logout_all::Request>,
|
body: Ruma<logout_all::Request>,
|
||||||
|
@ -318,7 +338,10 @@ pub fn logout_all_route(
|
||||||
Ok(logout_all::Response.into())
|
Ok(logout_all::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/account/password", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/account/password", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn change_password_route(
|
pub fn change_password_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<change_password::Request>,
|
body: Ruma<change_password::Request>,
|
||||||
|
@ -367,7 +390,10 @@ pub fn change_password_route(
|
||||||
Ok(change_password::Response.into())
|
Ok(change_password::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/account/deactivate", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/account/deactivate", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn deactivate_route(
|
pub fn deactivate_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<deactivate::Request>,
|
body: Ruma<deactivate::Request>,
|
||||||
|
@ -440,7 +466,7 @@ pub fn deactivate_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/capabilities")]
|
#[cfg_attr(feature = "conduit_bin", get("/_matrix/client/r0/capabilities"))]
|
||||||
pub fn get_capabilities_route() -> ConduitResult<get_capabilities::Response> {
|
pub fn get_capabilities_route() -> ConduitResult<get_capabilities::Response> {
|
||||||
let mut available = BTreeMap::new();
|
let mut available = BTreeMap::new();
|
||||||
available.insert(
|
available.insert(
|
||||||
|
@ -465,7 +491,10 @@ pub fn get_capabilities_route() -> ConduitResult<get_capabilities::Response> {
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/pushrules", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/pushrules", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn get_pushrules_all_route(
|
pub fn get_pushrules_all_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<get_pushrules_all::Request>,
|
body: Ruma<get_pushrules_all::Request>,
|
||||||
|
@ -486,10 +515,10 @@ pub fn get_pushrules_all_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put(
|
#[cfg_attr(feature = "conduit_bin", put(
|
||||||
"/_matrix/client/r0/pushrules/<_scope>/<_kind>/<_rule_id>",
|
"/_matrix/client/r0/pushrules/<_scope>/<_kind>/<_rule_id>",
|
||||||
//data = "<body>"
|
//data = "<body>"
|
||||||
)]
|
))]
|
||||||
pub fn set_pushrule_route(
|
pub fn set_pushrule_route(
|
||||||
//db: State<'_, Database>,
|
//db: State<'_, Database>,
|
||||||
//body: Ruma<set_pushrule::Request>,
|
//body: Ruma<set_pushrule::Request>,
|
||||||
|
@ -502,7 +531,10 @@ pub fn set_pushrule_route(
|
||||||
Ok(set_pushrule::Response.into())
|
Ok(set_pushrule::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put("/_matrix/client/r0/pushrules/<_scope>/<_kind>/<_rule_id>/enabled")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
put("/_matrix/client/r0/pushrules/<_scope>/<_kind>/<_rule_id>/enabled")
|
||||||
|
)]
|
||||||
pub fn set_pushrule_enabled_route(
|
pub fn set_pushrule_enabled_route(
|
||||||
_scope: String,
|
_scope: String,
|
||||||
_kind: String,
|
_kind: String,
|
||||||
|
@ -513,7 +545,10 @@ pub fn set_pushrule_enabled_route(
|
||||||
Ok(set_pushrule_enabled::Response.into())
|
Ok(set_pushrule_enabled::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/user/<_user_id>/filter/<_filter_id>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/user/<_user_id>/filter/<_filter_id>")
|
||||||
|
)]
|
||||||
pub fn get_filter_route(
|
pub fn get_filter_route(
|
||||||
_user_id: String,
|
_user_id: String,
|
||||||
_filter_id: String,
|
_filter_id: String,
|
||||||
|
@ -531,7 +566,10 @@ pub fn get_filter_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/user/<_user_id>/filter")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/user/<_user_id>/filter")
|
||||||
|
)]
|
||||||
pub fn create_filter_route(_user_id: String) -> ConduitResult<create_filter::Response> {
|
pub fn create_filter_route(_user_id: String) -> ConduitResult<create_filter::Response> {
|
||||||
// TODO
|
// TODO
|
||||||
Ok(create_filter::Response {
|
Ok(create_filter::Response {
|
||||||
|
@ -540,9 +578,12 @@ pub fn create_filter_route(_user_id: String) -> ConduitResult<create_filter::Res
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
put(
|
||||||
"/_matrix/client/r0/user/<_user_id>/account_data/<_type>",
|
"/_matrix/client/r0/user/<_user_id>/account_data/<_type>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn set_global_account_data_route(
|
pub fn set_global_account_data_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -568,9 +609,12 @@ pub fn set_global_account_data_route(
|
||||||
Ok(set_global_account_data::Response.into())
|
Ok(set_global_account_data::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get(
|
||||||
"/_matrix/client/r0/user/<_user_id>/account_data/<_type>",
|
"/_matrix/client/r0/user/<_user_id>/account_data/<_type>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn get_global_account_data_route(
|
pub fn get_global_account_data_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -595,7 +639,10 @@ pub fn get_global_account_data_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put("/_matrix/client/r0/profile/<_user_id>/displayname", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
put("/_matrix/client/r0/profile/<_user_id>/displayname", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn set_displayname_route(
|
pub fn set_displayname_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<set_display_name::Request>,
|
body: Ruma<set_display_name::Request>,
|
||||||
|
@ -661,7 +708,10 @@ pub fn set_displayname_route(
|
||||||
Ok(set_display_name::Response.into())
|
Ok(set_display_name::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/profile/<_user_id>/displayname", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/profile/<_user_id>/displayname", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn get_displayname_route(
|
pub fn get_displayname_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<get_display_name::Request>,
|
body: Ruma<get_display_name::Request>,
|
||||||
|
@ -674,7 +724,10 @@ pub fn get_displayname_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put("/_matrix/client/r0/profile/<_user_id>/avatar_url", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
put("/_matrix/client/r0/profile/<_user_id>/avatar_url", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn set_avatar_url_route(
|
pub fn set_avatar_url_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<set_avatar_url::Request>,
|
body: Ruma<set_avatar_url::Request>,
|
||||||
|
@ -751,7 +804,10 @@ pub fn set_avatar_url_route(
|
||||||
Ok(set_avatar_url::Response.into())
|
Ok(set_avatar_url::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/profile/<_user_id>/avatar_url", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/profile/<_user_id>/avatar_url", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn get_avatar_url_route(
|
pub fn get_avatar_url_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<get_avatar_url::Request>,
|
body: Ruma<get_avatar_url::Request>,
|
||||||
|
@ -764,7 +820,10 @@ pub fn get_avatar_url_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/profile/<_user_id>", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/profile/<_user_id>", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn get_profile_route(
|
pub fn get_profile_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<get_profile::Request>,
|
body: Ruma<get_profile::Request>,
|
||||||
|
@ -789,7 +848,10 @@ pub fn get_profile_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put("/_matrix/client/r0/presence/<_user_id>/status", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
put("/_matrix/client/r0/presence/<_user_id>/status", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn set_presence_route(
|
pub fn set_presence_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<set_presence::Request>,
|
body: Ruma<set_presence::Request>,
|
||||||
|
@ -819,7 +881,10 @@ pub fn set_presence_route(
|
||||||
Ok(set_presence::Response.into())
|
Ok(set_presence::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/keys/upload", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/keys/upload", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn upload_keys_route(
|
pub fn upload_keys_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<upload_keys::Request>,
|
body: Ruma<upload_keys::Request>,
|
||||||
|
@ -848,7 +913,10 @@ pub fn upload_keys_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/keys/query", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/keys/query", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn get_keys_route(
|
pub fn get_keys_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<get_keys::Request>,
|
body: Ruma<get_keys::Request>,
|
||||||
|
@ -925,7 +993,10 @@ pub fn get_keys_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/keys/claim", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/keys/claim", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn claim_keys_route(
|
pub fn claim_keys_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<claim_keys::Request>,
|
body: Ruma<claim_keys::Request>,
|
||||||
|
@ -953,7 +1024,10 @@ pub fn claim_keys_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/unstable/room_keys/version", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/unstable/room_keys/version", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn create_backup_route(
|
pub fn create_backup_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<create_backup::Request>,
|
body: Ruma<create_backup::Request>,
|
||||||
|
@ -966,9 +1040,12 @@ pub fn create_backup_route(
|
||||||
Ok(create_backup::Response { version }.into())
|
Ok(create_backup::Response { version }.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
put(
|
||||||
"/_matrix/client/unstable/room_keys/version/<_version>",
|
"/_matrix/client/unstable/room_keys/version/<_version>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn update_backup_route(
|
pub fn update_backup_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -982,7 +1059,10 @@ pub fn update_backup_route(
|
||||||
Ok(update_backup::Response.into())
|
Ok(update_backup::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/unstable/room_keys/version", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/unstable/room_keys/version", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn get_latest_backup_route(
|
pub fn get_latest_backup_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<get_latest_backup::Request>,
|
body: Ruma<get_latest_backup::Request>,
|
||||||
|
@ -1006,9 +1086,12 @@ pub fn get_latest_backup_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get(
|
||||||
"/_matrix/client/unstable/room_keys/version/<_version>",
|
"/_matrix/client/unstable/room_keys/version/<_version>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn get_backup_route(
|
pub fn get_backup_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -1033,7 +1116,11 @@ pub fn get_backup_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put("/_matrix/client/unstable/room_keys/keys", data = "<body>")]
|
/// Add the received backup_keys to the database.
|
||||||
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
put("/_matrix/client/unstable/room_keys/keys", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn add_backup_keys_route(
|
pub fn add_backup_keys_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<add_backup_keys::Request>,
|
body: Ruma<add_backup_keys::Request>,
|
||||||
|
@ -1060,7 +1147,10 @@ pub fn add_backup_keys_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/unstable/room_keys/keys", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/unstable/room_keys/keys", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn get_backup_keys_route(
|
pub fn get_backup_keys_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<get_backup_keys::Request>,
|
body: Ruma<get_backup_keys::Request>,
|
||||||
|
@ -1072,7 +1162,10 @@ pub fn get_backup_keys_route(
|
||||||
Ok(get_backup_keys::Response { rooms }.into())
|
Ok(get_backup_keys::Response { rooms }.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/rooms/<_room_id>/read_markers", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/rooms/<_room_id>/read_markers", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn set_read_marker_route(
|
pub fn set_read_marker_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<set_read_marker::Request>,
|
body: Ruma<set_read_marker::Request>,
|
||||||
|
@ -1134,9 +1227,12 @@ pub fn set_read_marker_route(
|
||||||
Ok(set_read_marker::Response.into())
|
Ok(set_read_marker::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
put(
|
||||||
"/_matrix/client/r0/rooms/<_room_id>/typing/<_user_id>",
|
"/_matrix/client/r0/rooms/<_room_id>/typing/<_user_id>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn create_typing_event_route(
|
pub fn create_typing_event_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -1163,7 +1259,10 @@ pub fn create_typing_event_route(
|
||||||
Ok(create_typing_event::Response.into())
|
Ok(create_typing_event::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/createRoom", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/createRoom", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn create_room_route(
|
pub fn create_room_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<create_room::Request>,
|
body: Ruma<create_room::Request>,
|
||||||
|
@ -1428,7 +1527,10 @@ pub fn create_room_route(
|
||||||
Ok(create_room::Response { room_id }.into())
|
Ok(create_room::Response { room_id }.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/joined_rooms", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/joined_rooms", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn joined_rooms_route(
|
pub fn joined_rooms_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<joined_rooms::Request>,
|
body: Ruma<joined_rooms::Request>,
|
||||||
|
@ -1445,9 +1547,12 @@ pub fn joined_rooms_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
put(
|
||||||
"/_matrix/client/r0/rooms/<_room_id>/redact/<_event_id>/<_txn_id>",
|
"/_matrix/client/r0/rooms/<_room_id>/redact/<_event_id>/<_txn_id>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn redact_event_route(
|
pub fn redact_event_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -1475,7 +1580,10 @@ pub fn redact_event_route(
|
||||||
Ok(redact_event::Response { event_id }.into())
|
Ok(redact_event::Response { event_id }.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put("/_matrix/client/r0/directory/room/<_room_alias>", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
put("/_matrix/client/r0/directory/room/<_room_alias>", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn create_alias_route(
|
pub fn create_alias_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<create_alias::Request>,
|
body: Ruma<create_alias::Request>,
|
||||||
|
@ -1491,7 +1599,10 @@ pub fn create_alias_route(
|
||||||
Ok(create_alias::Response.into())
|
Ok(create_alias::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[delete("/_matrix/client/r0/directory/room/<_room_alias>", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
delete("/_matrix/client/r0/directory/room/<_room_alias>", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn delete_alias_route(
|
pub fn delete_alias_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<delete_alias::Request>,
|
body: Ruma<delete_alias::Request>,
|
||||||
|
@ -1502,7 +1613,10 @@ pub fn delete_alias_route(
|
||||||
Ok(delete_alias::Response.into())
|
Ok(delete_alias::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/directory/room/<_room_alias>", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/directory/room/<_room_alias>", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn get_alias_route(
|
pub fn get_alias_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<get_alias::Request>,
|
body: Ruma<get_alias::Request>,
|
||||||
|
@ -1527,7 +1641,10 @@ pub fn get_alias_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/rooms/<_room_id>/join", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/rooms/<_room_id>/join", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn join_room_by_id_route(
|
pub 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>,
|
||||||
|
@ -1562,7 +1679,10 @@ pub fn join_room_by_id_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/join/<_room_id_or_alias>", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/join/<_room_id_or_alias>", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn join_room_by_id_or_alias_route(
|
pub 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>,
|
||||||
|
@ -1591,7 +1711,10 @@ pub fn join_room_by_id_or_alias_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/rooms/<_room_id>/leave", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/rooms/<_room_id>/leave", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn leave_room_route(
|
pub fn leave_room_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<leave_room::Request>,
|
body: Ruma<leave_room::Request>,
|
||||||
|
@ -1629,7 +1752,10 @@ pub fn leave_room_route(
|
||||||
Ok(leave_room::Response.into())
|
Ok(leave_room::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/rooms/<_room_id>/kick", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/rooms/<_room_id>/kick", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn kick_user_route(
|
pub fn kick_user_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<kick_user::Request>,
|
body: Ruma<kick_user::Request>,
|
||||||
|
@ -1668,7 +1794,10 @@ pub fn kick_user_route(
|
||||||
Ok(kick_user::Response.into())
|
Ok(kick_user::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/rooms/<_room_id>/joined_members", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/rooms/<_room_id>/joined_members", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn joined_members_route(
|
pub fn joined_members_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<joined_members::Request>,
|
body: Ruma<joined_members::Request>,
|
||||||
|
@ -1700,7 +1829,10 @@ pub fn joined_members_route(
|
||||||
Ok(joined_members::Response { joined }.into())
|
Ok(joined_members::Response { joined }.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/rooms/<_room_id>/ban", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/rooms/<_room_id>/ban", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn ban_user_route(
|
pub fn ban_user_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<ban_user::Request>,
|
body: Ruma<ban_user::Request>,
|
||||||
|
@ -1747,7 +1879,10 @@ pub fn ban_user_route(
|
||||||
Ok(ban_user::Response.into())
|
Ok(ban_user::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/rooms/<_room_id>/unban", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/rooms/<_room_id>/unban", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn unban_user_route(
|
pub fn unban_user_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<unban_user::Request>,
|
body: Ruma<unban_user::Request>,
|
||||||
|
@ -1785,7 +1920,10 @@ pub fn unban_user_route(
|
||||||
Ok(unban_user::Response.into())
|
Ok(unban_user::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/rooms/<_room_id>/forget", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/rooms/<_room_id>/forget", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn forget_room_route(
|
pub fn forget_room_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<forget_room::Request>,
|
body: Ruma<forget_room::Request>,
|
||||||
|
@ -1798,7 +1936,10 @@ pub fn forget_room_route(
|
||||||
Ok(forget_room::Response.into())
|
Ok(forget_room::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/rooms/<_room_id>/invite", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/rooms/<_room_id>/invite", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn invite_user_route(
|
pub fn invite_user_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<invite_user::Request>,
|
body: Ruma<invite_user::Request>,
|
||||||
|
@ -1829,7 +1970,10 @@ pub fn invite_user_route(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put("/_matrix/client/r0/directory/list/room/<_room_id>", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
put("/_matrix/client/r0/directory/list/room/<_room_id>", 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>,
|
||||||
|
@ -1843,7 +1987,10 @@ pub async fn set_room_visibility_route(
|
||||||
Ok(set_room_visibility::Response.into())
|
Ok(set_room_visibility::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/directory/list/room/<_room_id>", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/directory/list/room/<_room_id>", 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>,
|
||||||
|
@ -1859,7 +2006,10 @@ pub async fn get_room_visibility_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/publicRooms", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
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>,
|
||||||
|
@ -1908,7 +2058,10 @@ pub async fn get_public_rooms_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/publicRooms", data = "<_body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
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>,
|
||||||
|
@ -2020,7 +2173,10 @@ pub async fn get_public_rooms_filtered_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/user_directory/search", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/user_directory/search", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn search_users_route(
|
pub fn search_users_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<search_users::Request>,
|
body: Ruma<search_users::Request>,
|
||||||
|
@ -2060,7 +2216,10 @@ pub fn search_users_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/rooms/<_room_id>/members", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/rooms/<_room_id>/members", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn get_member_events_route(
|
pub fn get_member_events_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<get_member_events::Request>,
|
body: Ruma<get_member_events::Request>,
|
||||||
|
@ -2086,7 +2245,10 @@ pub fn get_member_events_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/thirdparty/protocols")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/thirdparty/protocols")
|
||||||
|
)]
|
||||||
pub fn get_protocols_route() -> ConduitResult<get_protocols::Response> {
|
pub fn get_protocols_route() -> ConduitResult<get_protocols::Response> {
|
||||||
warn!("TODO: get_protocols_route");
|
warn!("TODO: get_protocols_route");
|
||||||
Ok(get_protocols::Response {
|
Ok(get_protocols::Response {
|
||||||
|
@ -2095,9 +2257,12 @@ pub fn get_protocols_route() -> ConduitResult<get_protocols::Response> {
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get(
|
||||||
"/_matrix/client/r0/rooms/<_room_id>/event/<_event_id>",
|
"/_matrix/client/r0/rooms/<_room_id>/event/<_event_id>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn get_room_event_route(
|
pub fn get_room_event_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -2124,9 +2289,12 @@ pub fn get_room_event_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
put(
|
||||||
"/_matrix/client/r0/rooms/<_room_id>/send/<_event_type>/<_txn_id>",
|
"/_matrix/client/r0/rooms/<_room_id>/send/<_event_type>/<_txn_id>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn create_message_event_route(
|
pub fn create_message_event_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -2159,9 +2327,12 @@ pub fn create_message_event_route(
|
||||||
Ok(create_message_event::Response { event_id }.into())
|
Ok(create_message_event::Response { event_id }.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
put(
|
||||||
"/_matrix/client/r0/rooms/<_room_id>/state/<_event_type>/<_state_key>",
|
"/_matrix/client/r0/rooms/<_room_id>/state/<_event_type>/<_state_key>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn create_state_event_for_key_route(
|
pub fn create_state_event_for_key_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -2221,9 +2392,12 @@ pub fn create_state_event_for_key_route(
|
||||||
Ok(create_state_event_for_key::Response { event_id }.into())
|
Ok(create_state_event_for_key::Response { event_id }.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
put(
|
||||||
"/_matrix/client/r0/rooms/<_room_id>/state/<_event_type>",
|
"/_matrix/client/r0/rooms/<_room_id>/state/<_event_type>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn create_state_event_for_empty_key_route(
|
pub fn create_state_event_for_empty_key_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -2268,7 +2442,10 @@ pub fn create_state_event_for_empty_key_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/rooms/<_room_id>/state", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/rooms/<_room_id>/state", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn get_state_events_route(
|
pub fn get_state_events_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<get_state_events::Request>,
|
body: Ruma<get_state_events::Request>,
|
||||||
|
@ -2294,9 +2471,12 @@ pub fn get_state_events_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get(
|
||||||
"/_matrix/client/r0/rooms/<_room_id>/state/<_event_type>/<_state_key>",
|
"/_matrix/client/r0/rooms/<_room_id>/state/<_event_type>/<_state_key>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn get_state_events_for_key_route(
|
pub fn get_state_events_for_key_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -2329,9 +2509,12 @@ pub fn get_state_events_for_key_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get(
|
||||||
"/_matrix/client/r0/rooms/<_room_id>/state/<_event_type>",
|
"/_matrix/client/r0/rooms/<_room_id>/state/<_event_type>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn get_state_events_for_empty_key_route(
|
pub fn get_state_events_for_empty_key_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -2363,7 +2546,10 @@ pub fn get_state_events_for_empty_key_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/sync", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/sync", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn sync_route(
|
pub fn sync_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<sync_events::Request>,
|
body: Ruma<sync_events::Request>,
|
||||||
|
@ -2703,10 +2889,10 @@ pub fn sync_route(
|
||||||
.deserialize()
|
.deserialize()
|
||||||
.map_err(|_| Error::bad_database("EDU in database is invalid."))?;
|
.map_err(|_| Error::bad_database("EDU in database is invalid."))?;
|
||||||
if let Some(timestamp) = edu.content.last_active_ago {
|
if let Some(timestamp) = edu.content.last_active_ago {
|
||||||
let last_active_ago =
|
let mut last_active_ago = utils::millis_since_unix_epoch()
|
||||||
js_int::UInt::try_from(utils::millis_since_unix_epoch())
|
.try_into()
|
||||||
.expect("time is valid")
|
.expect("time is valid");
|
||||||
- timestamp;
|
last_active_ago -= timestamp;
|
||||||
edu.content.last_active_ago = Some(last_active_ago);
|
edu.content.last_active_ago = Some(last_active_ago);
|
||||||
}
|
}
|
||||||
Ok::<_, Error>(edu.into())
|
Ok::<_, Error>(edu.into())
|
||||||
|
@ -2745,9 +2931,12 @@ pub fn sync_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get(
|
||||||
"/_matrix/client/r0/rooms/<_room_id>/context/<_event_id>",
|
"/_matrix/client/r0/rooms/<_room_id>/context/<_event_id>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn get_context_route(
|
pub fn get_context_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -2847,7 +3036,10 @@ pub fn get_context_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/rooms/<_room_id>/messages", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/rooms/<_room_id>/messages", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn get_message_events_route(
|
pub fn get_message_events_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<get_message_events::Request>,
|
body: Ruma<get_message_events::Request>,
|
||||||
|
@ -2944,7 +3136,7 @@ pub fn get_message_events_route(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/voip/turnServer")]
|
#[cfg_attr(feature = "conduit_bin", get("/_matrix/client/r0/voip/turnServer"))]
|
||||||
pub fn turn_server_route() -> ConduitResult<create_message_event::Response> {
|
pub fn turn_server_route() -> ConduitResult<create_message_event::Response> {
|
||||||
Err(Error::BadRequest(
|
Err(Error::BadRequest(
|
||||||
ErrorKind::NotFound,
|
ErrorKind::NotFound,
|
||||||
|
@ -2952,7 +3144,7 @@ pub fn turn_server_route() -> ConduitResult<create_message_event::Response> {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/publicised_groups")]
|
#[cfg_attr(feature = "conduit_bin", post("/_matrix/client/r0/publicised_groups"))]
|
||||||
pub fn publicised_groups_route() -> ConduitResult<create_message_event::Response> {
|
pub fn publicised_groups_route() -> ConduitResult<create_message_event::Response> {
|
||||||
Err(Error::BadRequest(
|
Err(Error::BadRequest(
|
||||||
ErrorKind::NotFound,
|
ErrorKind::NotFound,
|
||||||
|
@ -2960,9 +3152,12 @@ pub fn publicised_groups_route() -> ConduitResult<create_message_event::Response
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
put(
|
||||||
"/_matrix/client/r0/sendToDevice/<_event_type>/<_txn_id>",
|
"/_matrix/client/r0/sendToDevice/<_event_type>/<_txn_id>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn send_event_to_device_route(
|
pub fn send_event_to_device_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -3009,7 +3204,7 @@ pub fn send_event_to_device_route(
|
||||||
Ok(send_event_to_device::Response.into())
|
Ok(send_event_to_device::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/media/r0/config")]
|
#[cfg_attr(feature = "conduit_bin", get("/_matrix/media/r0/config"))]
|
||||||
pub fn get_media_config_route(
|
pub fn get_media_config_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
) -> ConduitResult<get_media_config::Response> {
|
) -> ConduitResult<get_media_config::Response> {
|
||||||
|
@ -3019,7 +3214,10 @@ pub fn get_media_config_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/media/r0/upload", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/media/r0/upload", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn create_content_route(
|
pub fn create_content_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<create_content::Request>,
|
body: Ruma<create_content::Request>,
|
||||||
|
@ -3039,9 +3237,12 @@ pub fn create_content_route(
|
||||||
Ok(create_content::Response { content_uri: mxc }.into())
|
Ok(create_content::Response { content_uri: mxc }.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get(
|
||||||
"/_matrix/media/r0/download/<_server_name>/<_media_id>",
|
"/_matrix/media/r0/download/<_server_name>/<_media_id>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn get_content_route(
|
pub fn get_content_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -3064,9 +3265,12 @@ pub fn get_content_route(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get(
|
||||||
"/_matrix/media/r0/thumbnail/<_server_name>/<_media_id>",
|
"/_matrix/media/r0/thumbnail/<_server_name>/<_media_id>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn get_content_thumbnail_route(
|
pub fn get_content_thumbnail_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -3089,7 +3293,10 @@ pub fn get_content_thumbnail_route(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/devices", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/devices", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn get_devices_route(
|
pub fn get_devices_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<get_devices::Request>,
|
body: Ruma<get_devices::Request>,
|
||||||
|
@ -3105,7 +3312,10 @@ pub fn get_devices_route(
|
||||||
Ok(get_devices::Response { devices }.into())
|
Ok(get_devices::Response { devices }.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/devices/<_device_id>", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get("/_matrix/client/r0/devices/<_device_id>", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn get_device_route(
|
pub fn get_device_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<get_device::Request>,
|
body: Ruma<get_device::Request>,
|
||||||
|
@ -3121,7 +3331,10 @@ pub fn get_device_route(
|
||||||
Ok(get_device::Response { device }.into())
|
Ok(get_device::Response { device }.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put("/_matrix/client/r0/devices/<_device_id>", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
put("/_matrix/client/r0/devices/<_device_id>", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn update_device_route(
|
pub fn update_device_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<update_device::Request>,
|
body: Ruma<update_device::Request>,
|
||||||
|
@ -3142,7 +3355,10 @@ pub fn update_device_route(
|
||||||
Ok(update_device::Response.into())
|
Ok(update_device::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[delete("/_matrix/client/r0/devices/<_device_id>", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
delete("/_matrix/client/r0/devices/<_device_id>", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn delete_device_route(
|
pub fn delete_device_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<delete_device::Request>,
|
body: Ruma<delete_device::Request>,
|
||||||
|
@ -3186,7 +3402,10 @@ pub fn delete_device_route(
|
||||||
Ok(delete_device::Response.into())
|
Ok(delete_device::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/delete_devices", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/r0/delete_devices", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn delete_devices_route(
|
pub fn delete_devices_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<delete_devices::Request>,
|
body: Ruma<delete_devices::Request>,
|
||||||
|
@ -3231,7 +3450,10 @@ pub fn delete_devices_route(
|
||||||
Ok(delete_devices::Response.into())
|
Ok(delete_devices::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/unstable/keys/device_signing/upload", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/unstable/keys/device_signing/upload", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn upload_signing_keys_route(
|
pub fn upload_signing_keys_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<upload_signing_keys::Request>,
|
body: Ruma<upload_signing_keys::Request>,
|
||||||
|
@ -3282,7 +3504,10 @@ pub fn upload_signing_keys_route(
|
||||||
Ok(upload_signing_keys::Response.into())
|
Ok(upload_signing_keys::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/unstable/keys/signatures/upload", data = "<body>")]
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
post("/_matrix/client/unstable/keys/signatures/upload", data = "<body>")
|
||||||
|
)]
|
||||||
pub fn upload_signatures_route(
|
pub fn upload_signatures_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
body: Ruma<upload_signatures::Request>,
|
body: Ruma<upload_signatures::Request>,
|
||||||
|
@ -3331,7 +3556,7 @@ pub fn upload_signatures_route(
|
||||||
Ok(upload_signatures::Response.into())
|
Ok(upload_signatures::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/client/r0/pushers")]
|
#[cfg_attr(feature = "conduit_bin", get("/_matrix/client/r0/pushers"))]
|
||||||
pub fn pushers_route() -> ConduitResult<get_pushers::Response> {
|
pub fn pushers_route() -> ConduitResult<get_pushers::Response> {
|
||||||
Ok(get_pushers::Response {
|
Ok(get_pushers::Response {
|
||||||
pushers: Vec::new(),
|
pushers: Vec::new(),
|
||||||
|
@ -3339,7 +3564,7 @@ pub fn pushers_route() -> ConduitResult<get_pushers::Response> {
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/_matrix/client/r0/pushers/set")]
|
#[cfg_attr(feature = "conduit_bin", post("/_matrix/client/r0/pushers/set"))]
|
||||||
pub fn set_pushers_route() -> ConduitResult<get_pushers::Response> {
|
pub fn set_pushers_route() -> ConduitResult<get_pushers::Response> {
|
||||||
Ok(get_pushers::Response {
|
Ok(get_pushers::Response {
|
||||||
pushers: Vec::new(),
|
pushers: Vec::new(),
|
||||||
|
@ -3347,9 +3572,12 @@ pub fn set_pushers_route() -> ConduitResult<get_pushers::Response> {
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[put(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
put(
|
||||||
"/_matrix/client/r0/user/<_user_id>/rooms/<_room_id>/tags/<_tag>",
|
"/_matrix/client/r0/user/<_user_id>/rooms/<_room_id>/tags/<_tag>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn update_tag_route(
|
pub fn update_tag_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -3384,9 +3612,12 @@ pub fn update_tag_route(
|
||||||
Ok(create_tag::Response.into())
|
Ok(create_tag::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[delete(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
delete(
|
||||||
"/_matrix/client/r0/user/<_user_id>/rooms/<_room_id>/tags/<_tag>",
|
"/_matrix/client/r0/user/<_user_id>/rooms/<_room_id>/tags/<_tag>",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn delete_tag_route(
|
pub fn delete_tag_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -3418,9 +3649,12 @@ pub fn delete_tag_route(
|
||||||
Ok(delete_tag::Response.into())
|
Ok(delete_tag::Response.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get(
|
#[cfg_attr(
|
||||||
|
feature = "conduit_bin",
|
||||||
|
get(
|
||||||
"/_matrix/client/r0/user/<_user_id>/rooms/<_room_id>/tags",
|
"/_matrix/client/r0/user/<_user_id>/rooms/<_room_id>/tags",
|
||||||
data = "<body>"
|
data = "<body>"
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
pub fn get_tags_route(
|
pub fn get_tags_route(
|
||||||
db: State<'_, Database>,
|
db: State<'_, Database>,
|
||||||
|
@ -3445,6 +3679,7 @@ pub fn get_tags_route(
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "conduit_bin")]
|
||||||
#[options("/<_segments..>")]
|
#[options("/<_segments..>")]
|
||||||
pub fn options_route(
|
pub fn options_route(
|
||||||
_segments: rocket::http::uri::Segments<'_>,
|
_segments: rocket::http::uri::Segments<'_>,
|
||||||
|
|
19
src/error.rs
19
src/error.rs
|
@ -1,15 +1,17 @@
|
||||||
use crate::RumaResponse;
|
|
||||||
use http::StatusCode;
|
|
||||||
use log::error;
|
use log::error;
|
||||||
use rocket::{
|
use ruma::api::client::{error::ErrorKind, r0::uiaa::UiaaInfo};
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
#[cfg(feature = "conduit_bin")]
|
||||||
|
use {
|
||||||
|
crate::RumaResponse,
|
||||||
|
http::StatusCode,
|
||||||
|
rocket::{
|
||||||
response::{self, Responder},
|
response::{self, Responder},
|
||||||
Request,
|
Request,
|
||||||
|
},
|
||||||
|
ruma::api::client::{error::Error as RumaError, r0::uiaa::UiaaResponse},
|
||||||
};
|
};
|
||||||
use ruma::api::client::{
|
|
||||||
error::{Error as RumaError, ErrorKind},
|
|
||||||
r0::uiaa::{UiaaInfo, UiaaResponse},
|
|
||||||
};
|
|
||||||
use thiserror::Error;
|
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, Error>;
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
||||||
|
@ -46,6 +48,7 @@ impl Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "conduit_bin")]
|
||||||
impl<'r, 'o> Responder<'r, 'o> for Error
|
impl<'r, 'o> Responder<'r, 'o> for Error
|
||||||
where
|
where
|
||||||
'o: 'r,
|
'o: 'r,
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
pub mod client_server;
|
||||||
|
mod database;
|
||||||
|
mod error;
|
||||||
|
mod pdu;
|
||||||
|
pub mod push_rules;
|
||||||
|
mod ruma_wrapper;
|
||||||
|
mod utils;
|
||||||
|
|
||||||
|
pub use database::Database;
|
||||||
|
pub use error::{Error, Result};
|
||||||
|
pub use pdu::PduEvent;
|
||||||
|
pub use ruma_wrapper::{ConduitResult, Ruma, RumaResponse};
|
||||||
|
use std::ops::Deref;
|
||||||
|
|
||||||
|
pub struct State<'r, T: Send + Sync + 'static>(&'r T);
|
||||||
|
|
||||||
|
impl<'r, T: Send + Sync + 'static> Deref for State<'r, T> {
|
||||||
|
type Target = T;
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn deref(&self) -> &T {
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,7 @@ mod utils;
|
||||||
pub use database::Database;
|
pub use database::Database;
|
||||||
pub use error::{Error, Result};
|
pub use error::{Error, Result};
|
||||||
pub use pdu::PduEvent;
|
pub use pdu::PduEvent;
|
||||||
|
pub use rocket::State;
|
||||||
pub use ruma_wrapper::{ConduitResult, Ruma, RumaResponse};
|
pub use ruma_wrapper::{ConduitResult, Ruma, RumaResponse};
|
||||||
|
|
||||||
use rocket::{fairing::AdHoc, routes};
|
use rocket::{fairing::AdHoc, routes};
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use js_int::uint;
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
push::{
|
push::{
|
||||||
Action, ConditionalPushRule, ConditionalPushRuleInit, PatternedPushRule,
|
Action, ConditionalPushRule, ConditionalPushRuleInit, PatternedPushRule,
|
||||||
|
@ -185,7 +184,7 @@ pub fn encrypted_room_one_to_one_rule() -> ConditionalPushRule {
|
||||||
rule_id: ".m.rule.encrypted_room_one_to_one".to_owned(),
|
rule_id: ".m.rule.encrypted_room_one_to_one".to_owned(),
|
||||||
conditions: vec![
|
conditions: vec![
|
||||||
PushCondition::RoomMemberCount {
|
PushCondition::RoomMemberCount {
|
||||||
is: RoomMemberCountIs::from(uint!(2)..),
|
is: RoomMemberCountIs::from(2_u32.into()..),
|
||||||
},
|
},
|
||||||
PushCondition::EventMatch {
|
PushCondition::EventMatch {
|
||||||
key: "type".to_owned(),
|
key: "type".to_owned(),
|
||||||
|
@ -208,7 +207,7 @@ pub fn room_one_to_one_rule() -> ConditionalPushRule {
|
||||||
rule_id: ".m.rule.room_one_to_one".to_owned(),
|
rule_id: ".m.rule.room_one_to_one".to_owned(),
|
||||||
conditions: vec![
|
conditions: vec![
|
||||||
PushCondition::RoomMemberCount {
|
PushCondition::RoomMemberCount {
|
||||||
is: RoomMemberCountIs::from(uint!(2)..),
|
is: RoomMemberCountIs::from(2_u32.into()..),
|
||||||
},
|
},
|
||||||
PushCondition::EventMatch {
|
PushCondition::EventMatch {
|
||||||
key: "type".to_owned(),
|
key: "type".to_owned(),
|
||||||
|
|
|
@ -1,15 +1,24 @@
|
||||||
use crate::{utils, Error};
|
use crate::Error;
|
||||||
use log::warn;
|
use ruma::identifiers::{DeviceId, UserId};
|
||||||
use rocket::{
|
use std::{convert::TryInto, ops::Deref};
|
||||||
data::{Data, FromDataFuture, FromTransformedData, Transform, TransformFuture, Transformed},
|
|
||||||
|
#[cfg(feature = "conduit_bin")]
|
||||||
|
use {
|
||||||
|
crate::utils,
|
||||||
|
log::warn,
|
||||||
|
rocket::{
|
||||||
|
data::{
|
||||||
|
Data, FromDataFuture, FromTransformedData, Transform, TransformFuture, Transformed,
|
||||||
|
},
|
||||||
http::Status,
|
http::Status,
|
||||||
response::{self, Responder},
|
response::{self, Responder},
|
||||||
|
tokio::io::AsyncReadExt,
|
||||||
Outcome::*,
|
Outcome::*,
|
||||||
Request, State,
|
Request, State,
|
||||||
|
},
|
||||||
|
ruma::api::Endpoint,
|
||||||
|
std::io::Cursor,
|
||||||
};
|
};
|
||||||
use ruma::{api::Endpoint, DeviceId, UserId};
|
|
||||||
use std::{convert::TryInto, io::Cursor, ops::Deref};
|
|
||||||
use tokio::io::AsyncReadExt;
|
|
||||||
|
|
||||||
/// This struct converts rocket requests into ruma structs by converting them into http requests
|
/// This struct converts rocket requests into ruma structs by converting them into http requests
|
||||||
/// first.
|
/// first.
|
||||||
|
@ -20,6 +29,7 @@ pub struct Ruma<T> {
|
||||||
pub json_body: Option<Box<serde_json::value::RawValue>>, // This is None when body is not a valid string
|
pub json_body: Option<Box<serde_json::value::RawValue>>, // This is None when body is not a valid string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "conduit_bin")]
|
||||||
impl<'a, T: Endpoint> FromTransformedData<'a> for Ruma<T> {
|
impl<'a, T: Endpoint> FromTransformedData<'a> for Ruma<T> {
|
||||||
type Error = (); // TODO: Better error handling
|
type Error = (); // TODO: Better error handling
|
||||||
type Owned = Data;
|
type Owned = Data;
|
||||||
|
@ -119,6 +129,7 @@ impl<T: TryInto<http::Response<Vec<u8>>>> From<T> for RumaResponse<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "conduit_bin")]
|
||||||
impl<'r, 'o, T> Responder<'r, 'o> for RumaResponse<T>
|
impl<'r, 'o, T> Responder<'r, 'o> for RumaResponse<T>
|
||||||
where
|
where
|
||||||
T: Send + TryInto<http::Response<Vec<u8>>>,
|
T: Send + TryInto<http::Response<Vec<u8>>>,
|
||||||
|
|
|
@ -130,14 +130,14 @@ pub async fn send_request<T: Endpoint>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/.well-known/matrix/server")]
|
#[cfg_attr(feature = "conduit_bin",get("/.well-known/matrix/server"))]
|
||||||
pub fn well_known_server() -> Json<String> {
|
pub fn well_known_server() -> Json<String> {
|
||||||
rocket::response::content::Json(
|
rocket::response::content::Json(
|
||||||
json!({ "m.server": "matrixtesting.koesters.xyz:14004"}).to_string(),
|
json!({ "m.server": "matrixtesting.koesters.xyz:14004"}).to_string(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/federation/v1/version")]
|
#[cfg_attr(feature = "conduit_bin",get("/_matrix/federation/v1/version"))]
|
||||||
pub fn get_server_version() -> MatrixResult<get_server_version::Response, Error> {
|
pub fn get_server_version() -> MatrixResult<get_server_version::Response, Error> {
|
||||||
MatrixResult(Ok(get_server_version::Response {
|
MatrixResult(Ok(get_server_version::Response {
|
||||||
server: Some(get_server_version::Server {
|
server: Some(get_server_version::Server {
|
||||||
|
@ -147,7 +147,7 @@ pub fn get_server_version() -> MatrixResult<get_server_version::Response, Error>
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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> {
|
||||||
let mut verify_keys = BTreeMap::new();
|
let mut verify_keys = BTreeMap::new();
|
||||||
verify_keys.insert(
|
verify_keys.insert(
|
||||||
|
@ -177,7 +177,7 @@ pub fn get_server_keys(db: State<'_, Database>) -> Json<String> {
|
||||||
Json(response.to_string())
|
Json(response.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/_matrix/key/v2/server/<_key_id>")]
|
#[cfg_attr(feature = "conduit_bin",get("/_matrix/key/v2/server/<_key_id>"))]
|
||||||
pub fn get_server_keys_deprecated(db: State<'_, Database>, _key_id: String) -> Json<String> {
|
pub fn get_server_keys_deprecated(db: State<'_, Database>, _key_id: String) -> Json<String> {
|
||||||
get_server_keys(db)
|
get_server_keys(db)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue