Update ruma

next
Jonas Platte 2020-08-12 23:32:39 +02:00
parent 4b3d6e736f
commit 75ea0b3163
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
14 changed files with 152 additions and 122 deletions

137
Cargo.lock generated
View File

@ -17,9 +17,9 @@ checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"
[[package]]
name = "adler32"
version = "1.1.0"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "567b077b825e468cc974f0020d4082ee6e03132512f207ef1a02fd5d00d1f32d"
checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234"
[[package]]
name = "aead"
@ -100,10 +100,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
[[package]]
name = "async-trait"
version = "0.1.36"
name = "assign"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a265e3abeffdce30b2e26b7a11b222fe37c6067404001b434101457d0385eb92"
checksum = "4af5687fe33aec5e70ef14caac5e0d363e335e5e5d6385fb75978d0c241b1d67"
[[package]]
name = "async-trait"
version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caae68055714ff28740f310927e04f2eba76ff580b16fb18ed90073ee71646f7"
dependencies = [
"proc-macro2",
"quote",
@ -621,9 +627,9 @@ dependencies = [
[[package]]
name = "generic-array"
version = "0.14.3"
version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60fb4bb6bba52f78a471264d9a3b7d026cc0af47b22cd2cffbc0b787ca003e63"
checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817"
dependencies = [
"typenum",
"version_check",
@ -692,9 +698,9 @@ dependencies = [
[[package]]
name = "hashbrown"
version = "0.8.1"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34f595585f103464d8d2f6e9864682d74c1601fed5e07d62b1c9058dba8246fb"
checksum = "e91b62f79061a0bc2e046024cb7ba44b08419ed238ecbd9adbd787434b9e8c25"
dependencies = [
"autocfg",
]
@ -830,9 +836,9 @@ dependencies = [
[[package]]
name = "indexmap"
version = "1.5.0"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b88cd59ee5f71fea89a62248fc8f387d44400cefe05ef548466d61ced9029a7"
checksum = "86b45e59b16c76b11bf9738fd5d38879d3bd28ad292d7b313608becb17ae2df9"
dependencies = [
"autocfg",
"hashbrown",
@ -1303,6 +1309,15 @@ version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea"
[[package]]
name = "proc-macro-crate"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785"
dependencies = [
"toml",
]
[[package]]
name = "proc-macro-hack"
version = "0.5.18"
@ -1543,8 +1558,8 @@ dependencies = [
[[package]]
name = "ruma"
version = "0.1.0"
source = "git+https://github.com/ruma/ruma?rev=d5d2d1d893fa12d27960e4c58d6c09b215d06e95#d5d2d1d893fa12d27960e4c58d6c09b215d06e95"
version = "0.0.1"
source = "git+https://github.com/ruma/ruma?rev=987d48666cf166cf12100b5dbc61b5e3385c4014#987d48666cf166cf12100b5dbc61b5e3385c4014"
dependencies = [
"ruma-api",
"ruma-client-api",
@ -1552,14 +1567,13 @@ dependencies = [
"ruma-events",
"ruma-federation-api",
"ruma-identifiers",
"ruma-identifiers-macros",
"ruma-signatures",
]
[[package]]
name = "ruma-api"
version = "0.16.1"
source = "git+https://github.com/ruma/ruma?rev=d5d2d1d893fa12d27960e4c58d6c09b215d06e95#d5d2d1d893fa12d27960e4c58d6c09b215d06e95"
version = "0.17.0-alpha.1"
source = "git+https://github.com/ruma/ruma?rev=987d48666cf166cf12100b5dbc61b5e3385c4014#987d48666cf166cf12100b5dbc61b5e3385c4014"
dependencies = [
"http",
"percent-encoding",
@ -1573,9 +1587,10 @@ dependencies = [
[[package]]
name = "ruma-api-macros"
version = "0.16.1"
source = "git+https://github.com/ruma/ruma?rev=d5d2d1d893fa12d27960e4c58d6c09b215d06e95#d5d2d1d893fa12d27960e4c58d6c09b215d06e95"
version = "0.17.0-alpha.1"
source = "git+https://github.com/ruma/ruma?rev=987d48666cf166cf12100b5dbc61b5e3385c4014#987d48666cf166cf12100b5dbc61b5e3385c4014"
dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn",
@ -1583,9 +1598,10 @@ dependencies = [
[[package]]
name = "ruma-client-api"
version = "0.9.0"
source = "git+https://github.com/ruma/ruma?rev=d5d2d1d893fa12d27960e4c58d6c09b215d06e95#d5d2d1d893fa12d27960e4c58d6c09b215d06e95"
version = "0.10.0-alpha.1"
source = "git+https://github.com/ruma/ruma?rev=987d48666cf166cf12100b5dbc61b5e3385c4014#987d48666cf166cf12100b5dbc61b5e3385c4014"
dependencies = [
"assign",
"http",
"js_int",
"ruma-api",
@ -1601,9 +1617,10 @@ dependencies = [
[[package]]
name = "ruma-common"
version = "0.2.0"
source = "git+https://github.com/ruma/ruma?rev=d5d2d1d893fa12d27960e4c58d6c09b215d06e95#d5d2d1d893fa12d27960e4c58d6c09b215d06e95"
source = "git+https://github.com/ruma/ruma?rev=987d48666cf166cf12100b5dbc61b5e3385c4014#987d48666cf166cf12100b5dbc61b5e3385c4014"
dependencies = [
"js_int",
"ruma-identifiers",
"ruma-serde",
"serde",
"serde_json",
@ -1612,8 +1629,8 @@ dependencies = [
[[package]]
name = "ruma-events"
version = "0.21.3"
source = "git+https://github.com/ruma/ruma?rev=d5d2d1d893fa12d27960e4c58d6c09b215d06e95#d5d2d1d893fa12d27960e4c58d6c09b215d06e95"
version = "0.22.0-alpha.1"
source = "git+https://github.com/ruma/ruma?rev=987d48666cf166cf12100b5dbc61b5e3385c4014#987d48666cf166cf12100b5dbc61b5e3385c4014"
dependencies = [
"js_int",
"ruma-common",
@ -1627,9 +1644,10 @@ dependencies = [
[[package]]
name = "ruma-events-macros"
version = "0.21.3"
source = "git+https://github.com/ruma/ruma?rev=d5d2d1d893fa12d27960e4c58d6c09b215d06e95#d5d2d1d893fa12d27960e4c58d6c09b215d06e95"
version = "0.22.0-alpha.1"
source = "git+https://github.com/ruma/ruma?rev=987d48666cf166cf12100b5dbc61b5e3385c4014#987d48666cf166cf12100b5dbc61b5e3385c4014"
dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn",
@ -1637,8 +1655,8 @@ dependencies = [
[[package]]
name = "ruma-federation-api"
version = "0.0.2"
source = "git+https://github.com/ruma/ruma?rev=d5d2d1d893fa12d27960e4c58d6c09b215d06e95#d5d2d1d893fa12d27960e4c58d6c09b215d06e95"
version = "0.0.3"
source = "git+https://github.com/ruma/ruma?rev=987d48666cf166cf12100b5dbc61b5e3385c4014#987d48666cf166cf12100b5dbc61b5e3385c4014"
dependencies = [
"js_int",
"ruma-api",
@ -1652,29 +1670,42 @@ dependencies = [
[[package]]
name = "ruma-identifiers"
version = "0.17.1"
source = "git+https://github.com/ruma/ruma?rev=d5d2d1d893fa12d27960e4c58d6c09b215d06e95#d5d2d1d893fa12d27960e4c58d6c09b215d06e95"
version = "0.17.4"
source = "git+https://github.com/ruma/ruma?rev=987d48666cf166cf12100b5dbc61b5e3385c4014#987d48666cf166cf12100b5dbc61b5e3385c4014"
dependencies = [
"rand",
"ruma-identifiers-macros",
"ruma-identifiers-validation",
"serde",
"strum",
]
[[package]]
name = "ruma-identifiers-macros"
version = "0.17.1"
source = "git+https://github.com/ruma/ruma?rev=d5d2d1d893fa12d27960e4c58d6c09b215d06e95#d5d2d1d893fa12d27960e4c58d6c09b215d06e95"
version = "0.17.4"
source = "git+https://github.com/ruma/ruma?rev=987d48666cf166cf12100b5dbc61b5e3385c4014#987d48666cf166cf12100b5dbc61b5e3385c4014"
dependencies = [
"proc-macro2",
"quote",
"ruma-identifiers",
"ruma-identifiers-validation",
"syn",
]
[[package]]
name = "ruma-identifiers-validation"
version = "0.1.1"
source = "git+https://github.com/ruma/ruma?rev=987d48666cf166cf12100b5dbc61b5e3385c4014#987d48666cf166cf12100b5dbc61b5e3385c4014"
dependencies = [
"ruma-serde",
"serde",
"serde_json",
"strum",
]
[[package]]
name = "ruma-serde"
version = "0.2.2"
source = "git+https://github.com/ruma/ruma?rev=d5d2d1d893fa12d27960e4c58d6c09b215d06e95#d5d2d1d893fa12d27960e4c58d6c09b215d06e95"
version = "0.2.3"
source = "git+https://github.com/ruma/ruma?rev=987d48666cf166cf12100b5dbc61b5e3385c4014#987d48666cf166cf12100b5dbc61b5e3385c4014"
dependencies = [
"form_urlencoded",
"itoa",
@ -1686,7 +1717,7 @@ dependencies = [
[[package]]
name = "ruma-signatures"
version = "0.6.0-dev.1"
source = "git+https://github.com/ruma/ruma?rev=d5d2d1d893fa12d27960e4c58d6c09b215d06e95#d5d2d1d893fa12d27960e4c58d6c09b215d06e95"
source = "git+https://github.com/ruma/ruma?rev=987d48666cf166cf12100b5dbc61b5e3385c4014#987d48666cf166cf12100b5dbc61b5e3385c4014"
dependencies = [
"base64 0.12.3",
"ring",
@ -1818,18 +1849,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "serde"
version = "1.0.114"
version = "1.0.115"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3"
checksum = "e54c9a88f2da7238af84b5101443f0c0d0a3bbdc455e34a5c9497b1903ed55d5"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.114"
version = "1.0.115"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8e"
checksum = "609feed1d0a73cc36a0182a840a9b37b4a82f0b1150369f0536a9e3f2a31dc48"
dependencies = [
"proc-macro2",
"quote",
@ -1880,9 +1911,9 @@ dependencies = [
[[package]]
name = "signal-hook-registry"
version = "1.2.0"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41"
checksum = "a3e12110bc539e657a646068aaf5eb5b63af9d0c1f7b29c97113fad80e15f035"
dependencies = [
"arc-swap",
"libc",
@ -1914,9 +1945,9 @@ dependencies = [
[[package]]
name = "smallvec"
version = "1.4.1"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f"
checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252"
[[package]]
name = "socket2"
@ -2002,18 +2033,18 @@ checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0"
[[package]]
name = "strum"
version = "0.18.0"
version = "0.19.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57bd81eb48f4c437cadc685403cad539345bf703d78e63707418431cecd4522b"
checksum = "3924a58d165da3b7b2922c667ab0673c7b5fd52b5c19ea3442747bcb3cd15abe"
dependencies = [
"strum_macros",
]
[[package]]
name = "strum_macros"
version = "0.18.0"
version = "0.19.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87c85aa3f8ea653bfd3ddf25f7ee357ee4d204731f6aa9ad04002306f6e2774c"
checksum = "2d2ab682ecdcae7f5f45ae85cd7c1e6c8e68ea42c8a612d47fedf831c037146a"
dependencies = [
"heck",
"proc-macro2",
@ -2029,9 +2060,9 @@ checksum = "502d53007c02d7605a05df1c1a73ee436952781653da5d0bf57ad608f66932c1"
[[package]]
name = "syn"
version = "1.0.36"
version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cdb98bcb1f9d81d07b536179c269ea15999b5d14ea958196413869445bb5250"
checksum = "e69abc24912995b3038597a7a593be5053eb0fb44f3cc5beec0deb421790c1f4"
dependencies = [
"proc-macro2",
"quote",
@ -2213,9 +2244,9 @@ checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860"
[[package]]
name = "tracing"
version = "0.1.17"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbdf4ccd1652592b01286a5dbe1e2a77d78afaa34beadd9872a5f7396f92aaa9"
checksum = "6d79ca061b032d6ce30c660fded31189ca0b9922bf483cd70759f13a2d86786c"
dependencies = [
"cfg-if",
"log",
@ -2224,9 +2255,9 @@ dependencies = [
[[package]]
name = "tracing-core"
version = "0.1.11"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94ae75f0d28ae10786f3b1895c55fe72e79928fd5ccdebb5438c75e93fec178f"
checksum = "db63662723c316b43ca36d833707cc93dff82a02ba3d7e354f342682cc8b3545"
dependencies = [
"lazy_static",
]

View File

@ -17,7 +17,7 @@ edition = "2018"
rocket = { git = "https://github.com/timokoesters/Rocket.git", branch = "empty_parameters", features = ["tls"] }
tokio = "0.2.22" # Used for long polling
ruma = { git = "https://github.com/ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"], rev = "d5d2d1d893fa12d27960e4c58d6c09b215d06e95" } # Used for matrix spec type definitions and helpers
ruma = { git = "https://github.com/ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"], rev = "987d48666cf166cf12100b5dbc61b5e3385c4014" } # Used for matrix spec type definitions and helpers
#ruma = { path = "../ruma/ruma", features = ["rand", "client-api", "federation-api", "unstable-pre-spec", "unstable-synapse-quirks"] }
sled = "0.32.0" # Used for storing data permanently
log = "0.4.8" # Used for emitting log entries

View File

@ -14,7 +14,7 @@ use rocket::{delete, get, put};
)]
pub fn create_alias_route(
db: State<'_, Database>,
body: Ruma<create_alias::Request>,
body: Ruma<create_alias::IncomingRequest>,
) -> ConduitResult<create_alias::Response> {
if db.rooms.id_from_alias(&body.room_alias)?.is_some() {
return Err(Error::Conflict("Alias already exists."));
@ -32,7 +32,7 @@ pub fn create_alias_route(
)]
pub fn delete_alias_route(
db: State<'_, Database>,
body: Ruma<delete_alias::Request>,
body: Ruma<delete_alias::IncomingRequest>,
) -> ConduitResult<delete_alias::Response> {
db.rooms.set_alias(&body.room_alias, None, &db.globals)?;
@ -45,7 +45,7 @@ pub fn delete_alias_route(
)]
pub fn get_alias_route(
db: State<'_, Database>,
body: Ruma<get_alias::Request>,
body: Ruma<get_alias::IncomingRequest>,
) -> ConduitResult<get_alias::Response> {
if body.room_alias.server_name() != db.globals.server_name() {
todo!("ask remote server");

View File

@ -27,7 +27,7 @@ use rocket::{get, post, put};
)]
pub async fn get_public_rooms_filtered_route(
db: State<'_, Database>,
body: Ruma<get_public_rooms_filtered::Request>,
body: Ruma<get_public_rooms_filtered::IncomingRequest>,
) -> ConduitResult<get_public_rooms_filtered::Response> {
let limit = body.limit.map_or(10, u64::from);
let mut since = 0_u64;
@ -224,11 +224,11 @@ pub async fn get_public_rooms_filtered_route(
)]
pub async fn get_public_rooms_route(
db: State<'_, Database>,
body: Ruma<get_public_rooms::Request>,
body: Ruma<get_public_rooms::IncomingRequest>,
) -> ConduitResult<get_public_rooms::Response> {
let Ruma {
body:
get_public_rooms::Request {
get_public_rooms::IncomingRequest {
limit,
server,
since,
@ -246,7 +246,7 @@ pub async fn get_public_rooms_route(
} = get_public_rooms_filtered_route(
db,
Ruma {
body: get_public_rooms_filtered::Request {
body: get_public_rooms_filtered::IncomingRequest {
filter: None,
limit,
room_network: get_public_rooms_filtered::RoomNetwork::Matrix,

View File

@ -1,15 +1,17 @@
use super::State;
use super::SESSION_ID_LENGTH;
use super::{State, SESSION_ID_LENGTH};
use crate::{utils, ConduitResult, Database, Error, Ruma};
use ruma::api::client::{
error::ErrorKind,
r0::{
keys::{
self, claim_keys, get_key_changes, get_keys, upload_keys, upload_signatures,
upload_signing_keys,
use ruma::{
api::client::{
error::ErrorKind,
r0::{
keys::{
claim_keys, get_key_changes, get_keys, upload_keys, upload_signatures,
upload_signing_keys,
},
uiaa::{AuthFlow, UiaaInfo},
},
uiaa::{AuthFlow, UiaaInfo},
},
encryption::UnsignedDeviceInfo,
};
use std::collections::{BTreeMap, HashSet};
@ -54,7 +56,7 @@ pub fn upload_keys_route(
)]
pub fn get_keys_route(
db: State<'_, Database>,
body: Ruma<get_keys::Request>,
body: Ruma<get_keys::IncomingRequest>,
) -> ConduitResult<get_keys::Response> {
let sender_id = body.sender_id.as_ref().expect("user is authenticated");
@ -76,7 +78,7 @@ pub fn get_keys_route(
Error::bad_database("all_device_keys contained nonexistent device.")
})?;
keys.unsigned = Some(keys::UnsignedDeviceInfo {
keys.unsigned = Some(UnsignedDeviceInfo {
device_display_name: metadata.display_name,
});
@ -95,7 +97,7 @@ pub fn get_keys_route(
),
)?;
keys.unsigned = Some(keys::UnsignedDeviceInfo {
keys.unsigned = Some(UnsignedDeviceInfo {
device_display_name: metadata.display_name,
});
@ -278,7 +280,7 @@ pub fn upload_signatures_route(
)]
pub fn get_key_changes_route(
db: State<'_, Database>,
body: Ruma<get_key_changes::Request>,
body: Ruma<get_key_changes::IncomingRequest>,
) -> ConduitResult<get_key_changes::Response> {
let sender_id = body.sender_id.as_ref().expect("user is authenticated");

View File

@ -23,7 +23,7 @@ use rocket::{get, post};
)]
pub fn join_room_by_id_route(
db: State<'_, Database>,
body: Ruma<join_room_by_id::Request>,
body: Ruma<join_room_by_id::IncomingRequest>,
) -> ConduitResult<join_room_by_id::Response> {
let sender_id = body.sender_id.as_ref().expect("user is authenticated");
@ -76,7 +76,7 @@ pub fn join_room_by_id_or_alias_route(
sender_id: body.sender_id.clone(),
device_id: body.device_id.clone(),
json_body: None,
body: join_room_by_id::Request {
body: join_room_by_id::IncomingRequest {
room_id,
third_party_signed: body.third_party_signed.clone(),
},
@ -94,7 +94,7 @@ pub fn join_room_by_id_or_alias_route(
)]
pub fn leave_room_route(
db: State<'_, Database>,
body: Ruma<leave_room::Request>,
body: Ruma<leave_room::IncomingRequest>,
) -> ConduitResult<leave_room::Response> {
let sender_id = body.sender_id.as_ref().expect("user is authenticated");

View File

@ -2,7 +2,7 @@ use super::State;
use crate::{pdu::PduBuilder, ConduitResult, Database, Error, Ruma};
use ruma::api::client::{
error::ErrorKind,
r0::message::{create_message_event, get_message_events},
r0::message::{get_message_events, send_message_event},
};
use std::convert::TryInto;
@ -13,10 +13,10 @@ use rocket::{get, put};
feature = "conduit_bin",
put("/_matrix/client/r0/rooms/<_>/send/<_>/<_>", data = "<body>")
)]
pub fn create_message_event_route(
pub fn send_message_event_route(
db: State<'_, Database>,
body: Ruma<create_message_event::Request>,
) -> ConduitResult<create_message_event::Response> {
body: Ruma<send_message_event::IncomingRequest>,
) -> ConduitResult<send_message_event::Response> {
let sender_id = body.sender_id.as_ref().expect("user is authenticated");
let mut unsigned = serde_json::Map::new();
@ -41,7 +41,7 @@ pub fn create_message_event_route(
&db.account_data,
)?;
Ok(create_message_event::Response { event_id }.into())
Ok(send_message_event::Response { event_id }.into())
}
#[cfg_attr(

View File

@ -4,8 +4,8 @@ use ruma::{
api::client::{
error::ErrorKind,
r0::state::{
create_state_event_for_empty_key, create_state_event_for_key, get_state_events,
get_state_events_for_empty_key, get_state_events_for_key,
get_state_events, get_state_events_for_empty_key, get_state_events_for_key,
send_state_event_for_empty_key, send_state_event_for_key,
},
},
events::{room::canonical_alias, EventType},
@ -19,10 +19,10 @@ use rocket::{get, put};
feature = "conduit_bin",
put("/_matrix/client/r0/rooms/<_>/state/<_>/<_>", data = "<body>")
)]
pub fn create_state_event_for_key_route(
pub fn send_state_event_for_key_route(
db: State<'_, Database>,
body: Ruma<create_state_event_for_key::Request>,
) -> ConduitResult<create_state_event_for_key::Response> {
body: Ruma<send_state_event_for_key::IncomingRequest>,
) -> ConduitResult<send_state_event_for_key::Response> {
let sender_id = body.sender_id.as_ref().expect("user is authenticated");
let content = serde_json::from_str::<serde_json::Value>(
@ -78,21 +78,21 @@ pub fn create_state_event_for_key_route(
&db.account_data,
)?;
Ok(create_state_event_for_key::Response { event_id }.into())
Ok(send_state_event_for_key::Response { event_id }.into())
}
#[cfg_attr(
feature = "conduit_bin",
put("/_matrix/client/r0/rooms/<_>/state/<_>", data = "<body>")
)]
pub fn create_state_event_for_empty_key_route(
pub fn send_state_event_for_empty_key_route(
db: State<'_, Database>,
body: Ruma<create_state_event_for_empty_key::Request>,
) -> ConduitResult<create_state_event_for_empty_key::Response> {
// This just calls create_state_event_for_key_route
body: Ruma<send_state_event_for_empty_key::IncomingRequest>,
) -> ConduitResult<send_state_event_for_empty_key::Response> {
// This just calls send_state_event_for_key_route
let Ruma {
body:
create_state_event_for_empty_key::Request {
send_state_event_for_empty_key::IncomingRequest {
room_id,
event_type,
data,
@ -102,11 +102,11 @@ pub fn create_state_event_for_empty_key_route(
json_body,
} = body;
Ok(create_state_event_for_empty_key::Response {
event_id: create_state_event_for_key_route(
Ok(send_state_event_for_empty_key::Response {
event_id: send_state_event_for_key_route(
db,
Ruma {
body: create_state_event_for_key::Request {
body: send_state_event_for_key::IncomingRequest {
room_id,
event_type,
data,

View File

@ -14,7 +14,7 @@ use rocket::put;
)]
pub fn send_event_to_device_route(
db: State<'_, Database>,
body: Ruma<send_event_to_device::Request>,
body: Ruma<send_event_to_device::IncomingRequest>,
) -> ConduitResult<send_event_to_device::Response> {
let sender_id = body.sender_id.as_ref().expect("user is authenticated");

View File

@ -11,13 +11,9 @@ use rocket::post;
)]
pub fn search_users_route(
db: State<'_, Database>,
body: Ruma<search_users::Request>,
body: Ruma<search_users::IncomingRequest>,
) -> ConduitResult<search_users::Response> {
let limit = if let Some(limit) = body.limit {
u64::from(limit)
} else {
10
} as usize;
let limit = u64::from(body.limit) as usize;
let mut users = db.users.iter().filter_map(|user_id| {
// Filter out buggy users (they should not exist, but you never know...)

View File

@ -1,11 +1,11 @@
use crate::{ConduitResult, Error};
use ruma::api::client::{error::ErrorKind, r0::message::create_message_event};
use ruma::api::client::{error::ErrorKind, r0::message::send_message_event};
#[cfg(feature = "conduit_bin")]
use rocket::get;
#[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<send_message_event::Response> {
Err(Error::BadRequest(
ErrorKind::NotFound,
"There is no turn server yet.",

View File

@ -5,11 +5,12 @@ use ruma::{
error::ErrorKind,
r0::{
device::Device,
keys::{AlgorithmAndDeviceId, CrossSigningKey, DeviceKeys, KeyAlgorithm, OneTimeKey},
keys::{CrossSigningKey, OneTimeKey},
},
},
encryption::DeviceKeys,
events::{AnyToDeviceEvent, EventType},
DeviceId, Raw, UserId,
DeviceId, DeviceKeyAlgorithm, DeviceKeyId, Raw, UserId,
};
use std::{collections::BTreeMap, convert::TryFrom, mem, time::SystemTime};
@ -21,7 +22,7 @@ pub struct Users {
pub(super) userdeviceid_metadata: sled::Tree, // This is also used to check if a device exists
pub(super) token_userdeviceid: sled::Tree,
pub(super) onetimekeyid_onetimekeys: sled::Tree, // OneTimeKeyId = UserId + AlgorithmAndDeviceId
pub(super) onetimekeyid_onetimekeys: sled::Tree, // OneTimeKeyId = UserId + DeviceKeyId
pub(super) userid_lastonetimekeyupdate: sled::Tree, // LastOneTimeKeyUpdate = Count
pub(super) keychangeid_userid: sled::Tree, // KeyChangeId = UserId/RoomId + Count
pub(super) keyid_key: sled::Tree, // KeyId = UserId + KeyId (depends on key type)
@ -269,7 +270,7 @@ impl Users {
&self,
user_id: &UserId,
device_id: &DeviceId,
one_time_key_key: &AlgorithmAndDeviceId,
one_time_key_key: &DeviceKeyId,
one_time_key_value: &OneTimeKey,
globals: &super::globals::Globals,
) -> Result<()> {
@ -282,11 +283,11 @@ impl Users {
assert!(self.userdeviceid_metadata.get(&key)?.is_some());
key.push(0xff);
// TODO: Use AlgorithmAndDeviceId::to_string when it's available (and update everything,
// TODO: Use DeviceKeyId::to_string when it's available (and update everything,
// because there are no wrapping quotation marks anymore)
key.extend_from_slice(
&serde_json::to_string(one_time_key_key)
.expect("AlgorithmAndDeviceId::to_string always works")
.expect("DeviceKeyId::to_string always works")
.as_bytes(),
);
@ -319,9 +320,9 @@ impl Users {
&self,
user_id: &UserId,
device_id: &DeviceId,
key_algorithm: &KeyAlgorithm,
key_algorithm: &DeviceKeyAlgorithm,
globals: &super::globals::Globals,
) -> Result<Option<(AlgorithmAndDeviceId, OneTimeKey)>> {
) -> Result<Option<(DeviceKeyId, OneTimeKey)>> {
let mut prefix = user_id.to_string().as_bytes().to_vec();
prefix.push(0xff);
prefix.extend_from_slice(device_id.as_bytes());
@ -361,7 +362,7 @@ impl Users {
&self,
user_id: &UserId,
device_id: &DeviceId,
) -> Result<BTreeMap<KeyAlgorithm, UInt>> {
) -> Result<BTreeMap<DeviceKeyAlgorithm, UInt>> {
let mut userdeviceid = user_id.to_string().as_bytes().to_vec();
userdeviceid.push(0xff);
userdeviceid.extend_from_slice(device_id.as_bytes());
@ -374,13 +375,13 @@ impl Users {
.keys()
.map(|bytes| {
Ok::<_, Error>(
serde_json::from_slice::<AlgorithmAndDeviceId>(
serde_json::from_slice::<DeviceKeyId>(
&*bytes?.rsplit(|&b| b == 0xff).next().ok_or_else(|| {
Error::bad_database("OneTimeKey ID in db is invalid.")
})?,
)
.map_err(|_| Error::bad_database("AlgorithmAndDeviceID in db is invalid."))?
.0,
.map_err(|_| Error::bad_database("DeviceKeyId in db is invalid."))?
.algorithm(),
)
})
{

View File

@ -81,9 +81,9 @@ fn setup_rocket() -> rocket::Rocket {
client_server::search_users_route,
client_server::get_member_events_route,
client_server::get_protocols_route,
client_server::create_message_event_route,
client_server::create_state_event_for_key_route,
client_server::create_state_event_for_empty_key_route,
client_server::send_message_event_route,
client_server::send_state_event_for_key_route,
client_server::send_state_event_for_empty_key_route,
client_server::get_state_events_route,
client_server::get_state_events_for_key_route,
client_server::get_state_events_for_empty_key_route,

View File

@ -16,7 +16,7 @@ use {
tokio::io::AsyncReadExt,
Request, State,
},
ruma::api::Endpoint,
ruma::api::IncomingRequest,
std::io::Cursor,
};
@ -30,7 +30,7 @@ pub struct Ruma<T> {
}
#[cfg(feature = "conduit_bin")]
impl<'a, T: Endpoint> FromTransformedData<'a> for Ruma<T> {
impl<'a, T: IncomingRequest> FromTransformedData<'a> for Ruma<T> {
type Error = (); // TODO: Better error handling
type Owned = Data;
type Borrowed = Self::Owned;