Merge branch 'master' of https://git.koesters.xyz/timo/conduit into ruma-mono

This commit is contained in:
Devin Ragotzy 2020-07-25 13:46:28 -04:00
commit 61458536ab
7 changed files with 129 additions and 153 deletions

244
Cargo.lock generated
View File

@ -106,9 +106,9 @@ version = "0.1.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a265e3abeffdce30b2e26b7a11b222fe37c6067404001b434101457d0385eb92"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"syn 1.0.35",
"proc-macro2",
"quote",
"syn",
]
[[package]]
@ -154,15 +154,6 @@ version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b20b618342cf9891c292c4f5ac2cde7287cc5c87e87e9c769d617793607dec1"
[[package]]
name = "base64"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e"
dependencies = [
"byteorder",
]
[[package]]
name = "base64"
version = "0.11.0"
@ -322,7 +313,7 @@ dependencies = [
"aes-gcm",
"base64 0.12.3",
"hkdf",
"percent-encoding 2.1.0",
"percent-encoding",
"rand",
"sha2",
"time 0.2.16",
@ -402,7 +393,7 @@ dependencies = [
[[package]]
name = "devise"
version = "0.3.0"
source = "git+https://github.com/SergioBenitez/Devise.git?rev=e58b3ac9a#e58b3ac9afc3b6ff10a8aaf02a3e768a8f530089"
source = "git+https://github.com/SergioBenitez/Devise.git?rev=1e42a2691#1e42a2691ef9934a446b8ed0ca1c4c8cf283f8bf"
dependencies = [
"devise_codegen",
"devise_core",
@ -411,21 +402,22 @@ dependencies = [
[[package]]
name = "devise_codegen"
version = "0.3.0"
source = "git+https://github.com/SergioBenitez/Devise.git?rev=e58b3ac9a#e58b3ac9afc3b6ff10a8aaf02a3e768a8f530089"
source = "git+https://github.com/SergioBenitez/Devise.git?rev=1e42a2691#1e42a2691ef9934a446b8ed0ca1c4c8cf283f8bf"
dependencies = [
"devise_core",
"quote 1.0.7",
"quote",
]
[[package]]
name = "devise_core"
version = "0.3.0"
source = "git+https://github.com/SergioBenitez/Devise.git?rev=e58b3ac9a#e58b3ac9afc3b6ff10a8aaf02a3e768a8f530089"
source = "git+https://github.com/SergioBenitez/Devise.git?rev=1e42a2691#1e42a2691ef9934a446b8ed0ca1c4c8cf283f8bf"
dependencies = [
"bitflags",
"proc-macro2 1.0.19",
"quote 1.0.7",
"syn 1.0.35",
"proc-macro2",
"proc-macro2-diagnostics",
"quote",
"syn",
]
[[package]]
@ -597,9 +589,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39"
dependencies = [
"proc-macro-hack",
"proc-macro2 1.0.19",
"quote 1.0.7",
"syn 1.0.35",
"proc-macro2",
"quote",
"syn",
]
[[package]]
@ -865,10 +857,10 @@ dependencies = [
]
[[package]]
name = "instant"
version = "0.1.6"
name = "inlinable_string"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b141fdc7836c525d4d594027d318c84161ca17aaf8113ab1f81ab93ae897485"
checksum = "cb6ee2a7da03bfc3b66ca47c92c2e392fcc053ea040a85561749b026f7aad09a"
[[package]]
name = "iovec"
@ -1220,31 +1212,24 @@ dependencies = [
[[package]]
name = "pear"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5320f212db967792b67cfe12bd469d08afd6318a249bd917d5c19bc92200ab8a"
version = "0.2.0-dev"
source = "git+https://github.com/SergioBenitez/Pear.git?rev=4b68055#4b680556063568a42fcd4328335cdfdf7608be49"
dependencies = [
"inlinable_string",
"pear_codegen",
]
[[package]]
name = "pear_codegen"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfc1c836fdc3d1ef87c348b237b5b5c4dff922156fb2d968f57734f9669768ca"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.13",
"syn 0.15.44",
"version_check",
"yansi",
]
[[package]]
name = "percent-encoding"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
name = "pear_codegen"
version = "0.2.0-dev"
source = "git+https://github.com/SergioBenitez/Pear.git?rev=4b68055#4b680556063568a42fcd4328335cdfdf7608be49"
dependencies = [
"proc-macro2",
"proc-macro2-diagnostics",
"quote",
"syn",
]
[[package]]
name = "percent-encoding"
@ -1267,9 +1252,9 @@ version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a0ffd45cf79d88737d7cc85bfd5d2894bee1139b356e616fe85dc389c61aaf7"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"syn 1.0.35",
"proc-macro2",
"quote",
"syn",
]
[[package]]
@ -1332,29 +1317,23 @@ checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a"
[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
dependencies = [
"unicode-xid 0.1.0",
]
[[package]]
name = "proc-macro2"
version = "1.0.19"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12"
dependencies = [
"unicode-xid 0.2.1",
"unicode-xid",
]
[[package]]
name = "quote"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
name = "proc-macro2-diagnostics"
version = "0.1.0"
source = "git+https://github.com/SergioBenitez/proc-macro2-diagnostics.git?rev=13fbb43#13fbb43db72034b6f9660a9b00e338cebd8dcf44"
dependencies = [
"proc-macro2 0.4.30",
"proc-macro2",
"quote",
"syn",
"version_check",
"yansi",
]
[[package]]
@ -1363,7 +1342,7 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
dependencies = [
"proc-macro2 1.0.19",
"proc-macro2",
]
[[package]]
@ -1439,9 +1418,9 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d21b475ab879ef0e315ad99067fa25778c3b0377f57f1b00207448dac1a3144"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"syn 1.0.35",
"proc-macro2",
"quote",
"syn",
]
[[package]]
@ -1474,7 +1453,7 @@ dependencies = [
"mime",
"mime_guess",
"native-tls",
"percent-encoding 2.1.0",
"percent-encoding",
"pin-project-lite",
"serde",
"serde_urlencoded",
@ -1505,7 +1484,7 @@ dependencies = [
[[package]]
name = "rocket"
version = "0.5.0-dev"
source = "git+https://github.com/SergioBenitez/Rocket.git?rev=33e95f49008dcbc8dc51da7d37e0570059176b73#33e95f49008dcbc8dc51da7d37e0570059176b73"
source = "git+https://github.com/SergioBenitez/Rocket.git?rev=8d779caa22c63b15a6c3ceb75d8f6d4971b2eb67#8d779caa22c63b15a6c3ceb75d8f6d4971b2eb67"
dependencies = [
"async-trait",
"atomic",
@ -1530,21 +1509,19 @@ dependencies = [
[[package]]
name = "rocket_codegen"
version = "0.5.0-dev"
source = "git+https://github.com/SergioBenitez/Rocket.git?rev=33e95f49008dcbc8dc51da7d37e0570059176b73#33e95f49008dcbc8dc51da7d37e0570059176b73"
source = "git+https://github.com/SergioBenitez/Rocket.git?rev=8d779caa22c63b15a6c3ceb75d8f6d4971b2eb67#8d779caa22c63b15a6c3ceb75d8f6d4971b2eb67"
dependencies = [
"devise",
"glob",
"indexmap",
"quote 1.0.7",
"quote",
"rocket_http",
"version_check",
"yansi",
]
[[package]]
name = "rocket_http"
version = "0.5.0-dev"
source = "git+https://github.com/SergioBenitez/Rocket.git?rev=33e95f49008dcbc8dc51da7d37e0570059176b73#33e95f49008dcbc8dc51da7d37e0570059176b73"
source = "git+https://github.com/SergioBenitez/Rocket.git?rev=8d779caa22c63b15a6c3ceb75d8f6d4971b2eb67#8d779caa22c63b15a6c3ceb75d8f6d4971b2eb67"
dependencies = [
"cookie",
"http",
@ -1553,14 +1530,14 @@ dependencies = [
"log",
"mime",
"pear",
"percent-encoding 1.0.1",
"percent-encoding",
"ref-cast",
"smallvec",
"state",
"time 0.2.16",
"tokio",
"tokio-rustls",
"unicode-xid 0.2.1",
"unicode-xid",
]
[[package]]
@ -1583,7 +1560,7 @@ version = "0.16.1"
source = "git+https://github.com/ruma/ruma?rev=b55f827#b55f82742c88ea6d8744f37bacac5cbfa17a9029"
dependencies = [
"http",
"percent-encoding 2.1.0",
"percent-encoding",
"ruma-api-macros",
"ruma-identifiers",
"ruma-serde",
@ -1597,10 +1574,9 @@ name = "ruma-api-macros"
version = "0.16.1"
source = "git+https://github.com/ruma/ruma?rev=b55f827#b55f82742c88ea6d8744f37bacac5cbfa17a9029"
dependencies = [
"matches",
"proc-macro2 1.0.19",
"quote 1.0.7",
"syn 1.0.35",
"proc-macro2",
"quote",
"syn",
]
[[package]]
@ -1653,10 +1629,9 @@ name = "ruma-events-macros"
version = "0.21.3"
source = "git+https://github.com/ruma/ruma?rev=b55f827#b55f82742c88ea6d8744f37bacac5cbfa17a9029"
dependencies = [
"matches",
"proc-macro2 1.0.19",
"quote 1.0.7",
"syn 1.0.35",
"proc-macro2",
"quote",
"syn",
]
[[package]]
@ -1750,11 +1725,11 @@ dependencies = [
[[package]]
name = "rustls"
version = "0.16.0"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b25a18b1bf7387f0145e7f8324e700805aade3842dd3db2e74e4cdeb4677c09e"
checksum = "cac94b333ee2aac3284c5b8a1b7fb4dd11cba88c244e3fe33cdbd047af0eb693"
dependencies = [
"base64 0.10.1",
"base64 0.12.3",
"log",
"ring",
"sct",
@ -1846,9 +1821,9 @@ version = "1.0.114"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8e"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"syn 1.0.35",
"proc-macro2",
"quote",
"syn",
]
[[package]]
@ -1985,11 +1960,11 @@ version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"proc-macro2",
"quote",
"serde",
"serde_derive",
"syn 1.0.35",
"syn",
]
[[package]]
@ -1999,13 +1974,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11"
dependencies = [
"base-x",
"proc-macro2 1.0.19",
"quote 1.0.7",
"proc-macro2",
"quote",
"serde",
"serde_derive",
"serde_json",
"sha1",
"syn 1.0.35",
"syn",
]
[[package]]
@ -2030,9 +2005,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87c85aa3f8ea653bfd3ddf25f7ee357ee4d204731f6aa9ad04002306f6e2774c"
dependencies = [
"heck",
"proc-macro2 1.0.19",
"quote 1.0.7",
"syn 1.0.35",
"proc-macro2",
"quote",
"syn",
]
[[package]]
@ -2049,24 +2024,13 @@ checksum = "502d53007c02d7605a05df1c1a73ee436952781653da5d0bf57ad608f66932c1"
[[package]]
name = "syn"
version = "0.15.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.13",
"unicode-xid 0.1.0",
]
[[package]]
name = "syn"
version = "1.0.35"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb7f4c519df8c117855e19dd8cc851e89eb746fe7a73f0157e0d95fdec5369b0"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"unicode-xid 0.2.1",
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
@ -2098,9 +2062,9 @@ version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"syn 1.0.35",
"proc-macro2",
"quote",
"syn",
]
[[package]]
@ -2145,10 +2109,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa"
dependencies = [
"proc-macro-hack",
"proc-macro2 1.0.19",
"quote 1.0.7",
"proc-macro2",
"quote",
"standback",
"syn 1.0.35",
"syn",
]
[[package]]
@ -2186,16 +2150,16 @@ version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"syn 1.0.35",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tokio-rustls"
version = "0.12.3"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3068d891551949b37681724d6b73666787cc63fa8e255c812a41d2513aff9775"
checksum = "228139ddd4fea3fa345a29233009635235833e52807af7ea6448ead03890d6a9"
dependencies = [
"futures-core",
"rustls",
@ -2229,9 +2193,9 @@ dependencies = [
[[package]]
name = "toml"
version = "0.4.10"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f"
checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a"
dependencies = [
"serde",
]
@ -2307,12 +2271,6 @@ version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0"
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
[[package]]
name = "unicode-xid"
version = "0.2.1"
@ -2343,7 +2301,7 @@ checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb"
dependencies = [
"idna",
"matches",
"percent-encoding 2.1.0",
"percent-encoding",
]
[[package]]
@ -2395,9 +2353,9 @@ dependencies = [
"bumpalo",
"lazy_static",
"log",
"proc-macro2 1.0.19",
"quote 1.0.7",
"syn 1.0.35",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
@ -2419,7 +2377,7 @@ version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb071268b031a64d92fc6cf691715ca5a40950694d8f683c5bb43db7c730929e"
dependencies = [
"quote 1.0.7",
"quote",
"wasm-bindgen-macro-support",
]
@ -2429,9 +2387,9 @@ version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf592c807080719d1ff2f245a687cbadb3ed28b2077ed7084b47aba8b691f2c6"
dependencies = [
"proc-macro2 1.0.19",
"quote 1.0.7",
"syn 1.0.35",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]

View File

@ -12,7 +12,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rocket = { git = "https://github.com/SergioBenitez/Rocket.git", rev = "33e95f49008dcbc8dc51da7d37e0570059176b73", features = ["tls"] }
rocket = { git = "https://github.com/SergioBenitez/Rocket.git", rev = "8d779caa22c63b15a6c3ceb75d8f6d4971b2eb67", features = ["tls"] }
http = "0.2.1"
log = "0.4.8"
sled = "0.32.0"

View File

@ -1 +1 @@
nightly-2020-07-12
1.45.0

View File

@ -34,7 +34,7 @@ use ruma::{
media::{create_content, get_content, get_content_thumbnail, get_media_config},
membership::{
ban_user, forget_room, get_member_events, invite_user, join_room_by_id,
join_room_by_id_or_alias, kick_user, leave_room, unban_user,
join_room_by_id_or_alias, joined_rooms, kick_user, leave_room, unban_user,
},
message::{create_message_event, get_message_events},
presence::set_presence,
@ -1439,6 +1439,23 @@ pub fn create_room_route(
Ok(create_room::Response { room_id }.into())
}
#[get("/_matrix/client/r0/joined_rooms", data = "<body>")]
pub fn joined_rooms_route(
db: State<'_, Database>,
body: Ruma<joined_rooms::Request>,
) -> ConduitResult<joined_rooms::Response> {
let user_id = body.user_id.as_ref().expect("user is authenticated");
Ok(joined_rooms::Response {
joined_rooms: db
.rooms
.rooms_joined(&user_id)
.filter_map(|r| r.ok())
.collect(),
}
.into())
}
#[put(
"/_matrix/client/r0/rooms/<_room_id>/redact/<_event_id>/<_txn_id>",
data = "<body>"
@ -1872,10 +1889,10 @@ pub async fn get_public_rooms_route(
.into())
}
#[post("/_matrix/client/r0/publicRooms", data = "<body>")]
#[post("/_matrix/client/r0/publicRooms", data = "<_body>")]
pub async fn get_public_rooms_filtered_route(
db: State<'_, Database>,
body: Ruma<get_public_rooms_filtered::Request>,
_body: Ruma<get_public_rooms_filtered::Request>,
) -> ConduitResult<get_public_rooms_filtered::Response> {
let mut chunk = db
.rooms

View File

@ -1,4 +1,3 @@
#![feature(proc_macro_hygiene, decl_macro)]
#![warn(rust_2018_idioms)]
pub mod push_rules;
@ -67,6 +66,7 @@ fn setup_rocket() -> rocket::Rocket {
client_server::join_room_by_id_or_alias_route,
client_server::leave_room_route,
client_server::forget_room_route,
client_server::joined_rooms_route,
client_server::kick_user_route,
client_server::ban_user_route,
client_server::unban_user_route,

View File

@ -1,7 +1,7 @@
use crate::{utils, Error};
use log::warn;
use rocket::{
data::{Data, FromDataFuture, Transform, TransformFuture, Transformed, FromTransformedData},
data::{Data, FromDataFuture, FromTransformedData, Transform, TransformFuture, Transformed},
http::Status,
response::{self, Responder},
Outcome::*,
@ -125,7 +125,7 @@ impl<'r, 'o, T> Responder<'r, 'o> for RumaResponse<T>
where
T: Send + TryInto<http::Response<Vec<u8>>>,
T::Error: Send,
'o: 'r
'o: 'r,
{
fn respond_to(self, _: &'r Request<'_>) -> response::Result<'o> {
let http_response: Result<http::Response<_>, _> = self.0.try_into();
@ -143,8 +143,7 @@ where
let http_body = http_response.into_body();
response
.sized_body(http_body.len(), Cursor::new(http_body));
response.sized_body(http_body.len(), Cursor::new(http_body));
response.raw_header("Access-Control-Allow-Origin", "*");
response.raw_header(

View File

@ -29,6 +29,8 @@ GET /publicRooms lists newly-created room
GET /register yields a set of flows
GET /rooms/:room_id/state fetches entire room state
GET /rooms/:room_id/state/m.room.member/:user_id fetches my membership
GET /joined_rooms lists newly-created room
/joined_rooms returns only joined rooms
Getting push rules doesn't corrupt the cache SYN-390
POST /createRoom makes a private room
POST /createRoom makes a private room with invites