upgrade to latest ruma

This commit is contained in:
Charles Hall 2024-10-24 16:03:37 -07:00
parent 2dbb101140
commit c9c30fba30
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
8 changed files with 119 additions and 119 deletions

131
Cargo.lock generated
View file

@ -285,7 +285,7 @@ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"cexpr", "cexpr",
"clang-sys", "clang-sys",
"itertools", "itertools 0.12.1",
"lazy_static", "lazy_static",
"lazycell", "lazycell",
"proc-macro2", "proc-macro2",
@ -908,7 +908,7 @@ dependencies = [
"serde_yaml", "serde_yaml",
"sha-1", "sha-1",
"strum", "strum",
"thiserror", "thiserror 1.0.66",
"thread_local", "thread_local",
"tikv-jemallocator", "tikv-jemallocator",
"tokio", "tokio",
@ -1263,6 +1263,15 @@ dependencies = [
"either", "either",
] ]
[[package]]
name = "itertools"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
dependencies = [
"either",
]
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.11" version = "1.0.11"
@ -1618,7 +1627,7 @@ dependencies = [
"js-sys", "js-sys",
"once_cell", "once_cell",
"pin-project-lite", "pin-project-lite",
"thiserror", "thiserror 1.0.66",
] ]
[[package]] [[package]]
@ -1643,7 +1652,7 @@ dependencies = [
"opentelemetry-proto", "opentelemetry-proto",
"opentelemetry_sdk", "opentelemetry_sdk",
"prost", "prost",
"thiserror", "thiserror 1.0.66",
"tokio", "tokio",
"tonic", "tonic",
] ]
@ -1689,7 +1698,7 @@ dependencies = [
"percent-encoding", "percent-encoding",
"rand", "rand",
"serde_json", "serde_json",
"thiserror", "thiserror 1.0.66",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
] ]
@ -1757,7 +1766,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442"
dependencies = [ dependencies = [
"memchr", "memchr",
"thiserror", "thiserror 1.0.66",
"ucd-trie", "ucd-trie",
] ]
@ -1973,7 +1982,7 @@ dependencies = [
"memchr", "memchr",
"parking_lot", "parking_lot",
"protobuf", "protobuf",
"thiserror", "thiserror 1.0.66",
] ]
[[package]] [[package]]
@ -1993,7 +2002,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"itertools", "itertools 0.12.1",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn",
@ -2034,7 +2043,7 @@ dependencies = [
"rustc-hash 2.0.0", "rustc-hash 2.0.0",
"rustls", "rustls",
"socket2", "socket2",
"thiserror", "thiserror 1.0.66",
"tokio", "tokio",
"tracing", "tracing",
] ]
@ -2051,7 +2060,7 @@ dependencies = [
"rustc-hash 2.0.0", "rustc-hash 2.0.0",
"rustls", "rustls",
"slab", "slab",
"thiserror", "thiserror 1.0.66",
"tinyvec", "tinyvec",
"tracing", "tracing",
] ]
@ -2233,8 +2242,8 @@ dependencies = [
[[package]] [[package]]
name = "ruma" name = "ruma"
version = "0.10.1" version = "0.11.1"
source = "git+https://github.com/ruma/ruma?branch=main#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" source = "git+https://github.com/ruma/ruma?branch=main#a77a6ad2138363deaeac544759af1ef0b31d1e0a"
dependencies = [ dependencies = [
"assign", "assign",
"js_int", "js_int",
@ -2254,8 +2263,8 @@ dependencies = [
[[package]] [[package]]
name = "ruma-appservice-api" name = "ruma-appservice-api"
version = "0.10.0" version = "0.11.0"
source = "git+https://github.com/ruma/ruma?branch=main#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" source = "git+https://github.com/ruma/ruma?branch=main#a77a6ad2138363deaeac544759af1ef0b31d1e0a"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -2266,8 +2275,8 @@ dependencies = [
[[package]] [[package]]
name = "ruma-client-api" name = "ruma-client-api"
version = "0.18.0" version = "0.19.0"
source = "git+https://github.com/ruma/ruma?branch=main#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" source = "git+https://github.com/ruma/ruma?branch=main#a77a6ad2138363deaeac544759af1ef0b31d1e0a"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"assign", "assign",
@ -2282,15 +2291,15 @@ dependencies = [
"serde", "serde",
"serde_html_form", "serde_html_form",
"serde_json", "serde_json",
"thiserror", "thiserror 2.0.1",
"url", "url",
"web-time", "web-time",
] ]
[[package]] [[package]]
name = "ruma-common" name = "ruma-common"
version = "0.13.0" version = "0.14.1"
source = "git+https://github.com/ruma/ruma?branch=main#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" source = "git+https://github.com/ruma/ruma?branch=main#a77a6ad2138363deaeac544759af1ef0b31d1e0a"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"base64 0.22.1", "base64 0.22.1",
@ -2308,7 +2317,7 @@ dependencies = [
"serde", "serde",
"serde_html_form", "serde_html_form",
"serde_json", "serde_json",
"thiserror", "thiserror 2.0.1",
"time", "time",
"tracing", "tracing",
"url", "url",
@ -2319,8 +2328,8 @@ dependencies = [
[[package]] [[package]]
name = "ruma-events" name = "ruma-events"
version = "0.28.1" version = "0.29.1"
source = "git+https://github.com/ruma/ruma?branch=main#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" source = "git+https://github.com/ruma/ruma?branch=main#a77a6ad2138363deaeac544759af1ef0b31d1e0a"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"indexmap 2.6.0", "indexmap 2.6.0",
@ -2333,7 +2342,7 @@ dependencies = [
"ruma-macros", "ruma-macros",
"serde", "serde",
"serde_json", "serde_json",
"thiserror", "thiserror 2.0.1",
"tracing", "tracing",
"url", "url",
"web-time", "web-time",
@ -2342,8 +2351,8 @@ dependencies = [
[[package]] [[package]]
name = "ruma-federation-api" name = "ruma-federation-api"
version = "0.9.0" version = "0.10.0"
source = "git+https://github.com/ruma/ruma?branch=main#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" source = "git+https://github.com/ruma/ruma?branch=main#a77a6ad2138363deaeac544759af1ef0b31d1e0a"
dependencies = [ dependencies = [
"bytes", "bytes",
"http", "http",
@ -2360,17 +2369,17 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers-validation" name = "ruma-identifiers-validation"
version = "0.9.5" version = "0.10.0"
source = "git+https://github.com/ruma/ruma?branch=main#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" source = "git+https://github.com/ruma/ruma?branch=main#a77a6ad2138363deaeac544759af1ef0b31d1e0a"
dependencies = [ dependencies = [
"js_int", "js_int",
"thiserror", "thiserror 2.0.1",
] ]
[[package]] [[package]]
name = "ruma-identity-service-api" name = "ruma-identity-service-api"
version = "0.9.0" version = "0.10.0"
source = "git+https://github.com/ruma/ruma?branch=main#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" source = "git+https://github.com/ruma/ruma?branch=main#a77a6ad2138363deaeac544759af1ef0b31d1e0a"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -2379,8 +2388,8 @@ dependencies = [
[[package]] [[package]]
name = "ruma-macros" name = "ruma-macros"
version = "0.13.0" version = "0.14.0"
source = "git+https://github.com/ruma/ruma?branch=main#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" source = "git+https://github.com/ruma/ruma?branch=main#a77a6ad2138363deaeac544759af1ef0b31d1e0a"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"once_cell", "once_cell",
@ -2395,8 +2404,8 @@ dependencies = [
[[package]] [[package]]
name = "ruma-push-gateway-api" name = "ruma-push-gateway-api"
version = "0.9.0" version = "0.10.0"
source = "git+https://github.com/ruma/ruma?branch=main#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" source = "git+https://github.com/ruma/ruma?branch=main#a77a6ad2138363deaeac544759af1ef0b31d1e0a"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -2407,21 +2416,21 @@ dependencies = [
[[package]] [[package]]
name = "ruma-server-util" name = "ruma-server-util"
version = "0.3.0" version = "0.4.0"
source = "git+https://github.com/ruma/ruma?branch=main#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" source = "git+https://github.com/ruma/ruma?branch=main#a77a6ad2138363deaeac544759af1ef0b31d1e0a"
dependencies = [ dependencies = [
"headers", "headers",
"http", "http",
"http-auth", "http-auth",
"ruma-common", "ruma-common",
"thiserror", "thiserror 2.0.1",
"tracing", "tracing",
] ]
[[package]] [[package]]
name = "ruma-signatures" name = "ruma-signatures"
version = "0.15.0" version = "0.16.0"
source = "git+https://github.com/ruma/ruma?branch=main#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" source = "git+https://github.com/ruma/ruma?branch=main#a77a6ad2138363deaeac544759af1ef0b31d1e0a"
dependencies = [ dependencies = [
"base64 0.22.1", "base64 0.22.1",
"ed25519-dalek", "ed25519-dalek",
@ -2431,21 +2440,21 @@ dependencies = [
"serde_json", "serde_json",
"sha2", "sha2",
"subslice", "subslice",
"thiserror", "thiserror 2.0.1",
] ]
[[package]] [[package]]
name = "ruma-state-res" name = "ruma-state-res"
version = "0.11.0" version = "0.12.0"
source = "git+https://github.com/ruma/ruma?branch=main#1ae98db9c44f46a590f4c76baf5cef70ebb6970d" source = "git+https://github.com/ruma/ruma?branch=main#a77a6ad2138363deaeac544759af1ef0b31d1e0a"
dependencies = [ dependencies = [
"itertools", "itertools 0.13.0",
"js_int", "js_int",
"ruma-common", "ruma-common",
"ruma-events", "ruma-events",
"serde", "serde",
"serde_json", "serde_json",
"thiserror", "thiserror 2.0.1",
"tracing", "tracing",
] ]
@ -2820,7 +2829,7 @@ checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085"
dependencies = [ dependencies = [
"num-bigint", "num-bigint",
"num-traits", "num-traits",
"thiserror", "thiserror 1.0.66",
"time", "time",
] ]
@ -2910,9 +2919,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.86" version = "2.0.87"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e89275301d38033efb81a6e60e3497e734dfcc62571f2854bf4b16690398824c" checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2956,7 +2965,16 @@ version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d171f59dbaa811dbbb1aee1e73db92ec2b122911a48e1390dfe327a821ddede" checksum = "5d171f59dbaa811dbbb1aee1e73db92ec2b122911a48e1390dfe327a821ddede"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl 1.0.66",
]
[[package]]
name = "thiserror"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07c1e40dd48a282ae8edc36c732cbc219144b87fb6a4c7316d611c6b1f06ec0c"
dependencies = [
"thiserror-impl 2.0.1",
] ]
[[package]] [[package]]
@ -2970,6 +2988,17 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "thiserror-impl"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "874aa7e446f1da8d9c3a5c95b1c5eb41d800045252121dc7f8e0ba370cee55f5"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "thread_local" name = "thread_local"
version = "1.1.8" version = "1.1.8"
@ -3093,7 +3122,7 @@ checksum = "0d4770b8024672c1101b3f6733eab95b18007dbe0847a8afe341fcf79e06043f"
dependencies = [ dependencies = [
"either", "either",
"futures-util", "futures-util",
"thiserror", "thiserror 1.0.66",
"tokio", "tokio",
] ]
@ -3371,7 +3400,7 @@ dependencies = [
"once_cell", "once_cell",
"rand", "rand",
"smallvec", "smallvec",
"thiserror", "thiserror 1.0.66",
"tinyvec", "tinyvec",
"tokio", "tokio",
"tracing", "tracing",
@ -3393,7 +3422,7 @@ dependencies = [
"rand", "rand",
"resolv-conf", "resolv-conf",
"smallvec", "smallvec",
"thiserror", "thiserror 1.0.66",
"tokio", "tokio",
"tracing", "tracing",
"trust-dns-proto", "trust-dns-proto",

View file

@ -17,7 +17,7 @@ use ruma::{
federation, federation,
}, },
serde::Raw, serde::Raw,
DeviceKeyAlgorithm, OwnedDeviceId, OwnedUserId, UserId, OneTimeKeyAlgorithm, OwnedDeviceId, OwnedUserId, UserId,
}; };
use serde_json::json; use serde_json::json;
use tracing::debug; use tracing::debug;
@ -474,7 +474,16 @@ pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
let (_, our_master_key) = services() let (_, our_master_key) = services()
.users .users
.parse_master_key(&user, &our_master_key)?; .parse_master_key(&user, &our_master_key)?;
master_key.signatures.extend(our_master_key.signatures);
for (entity, v) in &*our_master_key.signatures {
for (key_identifier, value) in v {
master_key.signatures.insert_signature(
entity.clone(),
key_identifier.clone(),
value.clone(),
);
}
}
} }
let json = serde_json::to_value(master_key) let json = serde_json::to_value(master_key)
.expect("to_value always works"); .expect("to_value always works");
@ -525,7 +534,7 @@ fn add_unsigned_device_display_name(
pub(crate) async fn claim_keys_helper( pub(crate) async fn claim_keys_helper(
one_time_keys_input: &BTreeMap< one_time_keys_input: &BTreeMap<
OwnedUserId, OwnedUserId,
BTreeMap<OwnedDeviceId, DeviceKeyAlgorithm>, BTreeMap<OwnedDeviceId, OneTimeKeyAlgorithm>,
>, >,
) -> Result<claim_keys::v3::Response> { ) -> Result<claim_keys::v3::Response> {
let mut one_time_keys = BTreeMap::new(); let mut one_time_keys = BTreeMap::new();

View file

@ -670,11 +670,13 @@ pub(crate) async fn get_content_thumbnail_legacy_route(
AmResponse { AmResponse {
file, file,
content_type, content_type,
..
}: AmResponse, }: AmResponse,
) -> LegacyResponse { ) -> LegacyResponse {
LegacyResponse { LegacyResponse {
file, file,
content_type, content_type,
content_disposition: None,
cross_origin_resource_policy: Some("cross-origin".to_owned()), cross_origin_resource_policy: Some("cross-origin".to_owned()),
} }
} }
@ -833,6 +835,7 @@ async fn get_content_thumbnail_route_ruma(
authenticated_media_client::get_content_thumbnail::v1::Response { authenticated_media_client::get_content_thumbnail::v1::Response {
file, file,
content_type, content_type,
content_disposition: None,
} }
}; };

View file

@ -4,7 +4,7 @@ use ruma::{
push::{ push::{
delete_pushrule, get_pushers, get_pushrule, get_pushrule_actions, delete_pushrule, get_pushers, get_pushrule, get_pushrule_actions,
get_pushrule_enabled, get_pushrules_all, set_pusher, set_pushrule, get_pushrule_enabled, get_pushrules_all, set_pusher, set_pushrule,
set_pushrule_actions, set_pushrule_enabled, RuleScope, set_pushrule_actions, set_pushrule_enabled,
}, },
}, },
events::{push_rules::PushRulesEvent, GlobalAccountDataEventType}, events::{push_rules::PushRulesEvent, GlobalAccountDataEventType},
@ -89,13 +89,6 @@ pub(crate) async fn set_pushrule_route(
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let body = body.body; let body = body.body;
if body.scope != RuleScope::Global {
return Err(Error::BadRequest(
ErrorKind::InvalidParam,
"Scopes other than 'global' are not supported.",
));
}
let event = services() let event = services()
.account_data .account_data
.get( .get(
@ -168,13 +161,6 @@ pub(crate) async fn get_pushrule_actions_route(
) -> Result<Ra<get_pushrule_actions::v3::Response>> { ) -> Result<Ra<get_pushrule_actions::v3::Response>> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if body.scope != RuleScope::Global {
return Err(Error::BadRequest(
ErrorKind::InvalidParam,
"Scopes other than 'global' are not supported.",
));
}
let event = services() let event = services()
.account_data .account_data
.get( .get(
@ -213,13 +199,6 @@ pub(crate) async fn set_pushrule_actions_route(
) -> Result<Ra<set_pushrule_actions::v3::Response>> { ) -> Result<Ra<set_pushrule_actions::v3::Response>> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if body.scope != RuleScope::Global {
return Err(Error::BadRequest(
ErrorKind::InvalidParam,
"Scopes other than 'global' are not supported.",
));
}
let event = services() let event = services()
.account_data .account_data
.get( .get(
@ -268,13 +247,6 @@ pub(crate) async fn get_pushrule_enabled_route(
) -> Result<Ra<get_pushrule_enabled::v3::Response>> { ) -> Result<Ra<get_pushrule_enabled::v3::Response>> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if body.scope != RuleScope::Global {
return Err(Error::BadRequest(
ErrorKind::InvalidParam,
"Scopes other than 'global' are not supported.",
));
}
let event = services() let event = services()
.account_data .account_data
.get( .get(
@ -314,13 +286,6 @@ pub(crate) async fn set_pushrule_enabled_route(
) -> Result<Ra<set_pushrule_enabled::v3::Response>> { ) -> Result<Ra<set_pushrule_enabled::v3::Response>> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if body.scope != RuleScope::Global {
return Err(Error::BadRequest(
ErrorKind::InvalidParam,
"Scopes other than 'global' are not supported.",
));
}
let event = services() let event = services()
.account_data .account_data
.get( .get(
@ -369,13 +334,6 @@ pub(crate) async fn delete_pushrule_route(
) -> Result<Ra<delete_pushrule::v3::Response>> { ) -> Result<Ra<delete_pushrule::v3::Response>> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if body.scope != RuleScope::Global {
return Err(Error::BadRequest(
ErrorKind::InvalidParam,
"Scopes other than 'global' are not supported.",
));
}
let event = services() let event = services()
.account_data .account_data
.get( .get(

View file

@ -59,7 +59,7 @@ use ruma::{
uint, user_id, CanonicalJsonObject, CanonicalJsonValue, EventId, uint, user_id, CanonicalJsonObject, CanonicalJsonValue, EventId,
MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedServerName, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedServerName,
OwnedServerSigningKeyId, OwnedSigningKeyId, OwnedUserId, RoomId, OwnedServerSigningKeyId, OwnedSigningKeyId, OwnedUserId, RoomId,
ServerName, ServerName, Signatures,
}; };
use serde_json::value::{to_raw_value, RawValue as RawJsonValue}; use serde_json::value::{to_raw_value, RawValue as RawJsonValue};
use tokio::sync::RwLock; use tokio::sync::RwLock;
@ -617,7 +617,7 @@ pub(crate) async fn get_server_keys_route() -> Result<impl IntoResponse> {
server_name: services().globals.server_name().to_owned(), server_name: services().globals.server_name().to_owned(),
verify_keys, verify_keys,
old_verify_keys, old_verify_keys,
signatures: BTreeMap::new(), signatures: Signatures::new(),
valid_until_ts: keys.valid_until_ts, valid_until_ts: keys.valid_until_ts,
}) })
.expect("static conversion, no errors"), .expect("static conversion, no errors"),

View file

@ -5,8 +5,9 @@ use ruma::{
encryption::{CrossSigningKey, DeviceKeys, OneTimeKey}, encryption::{CrossSigningKey, DeviceKeys, OneTimeKey},
events::{AnyToDeviceEvent, StateEventType}, events::{AnyToDeviceEvent, StateEventType},
serde::Raw, serde::Raw,
DeviceId, DeviceKeyAlgorithm, DeviceKeyId, MilliSecondsSinceUnixEpoch, DeviceId, MilliSecondsSinceUnixEpoch, OneTimeKeyAlgorithm, OneTimeKeyName,
OwnedDeviceId, OwnedDeviceKeyId, OwnedMxcUri, OwnedUserId, UInt, UserId, OwnedDeviceId, OwnedKeyId, OwnedMxcUri, OwnedOneTimeKeyId, OwnedUserId,
UInt, UserId,
}; };
use tracing::warn; use tracing::warn;
@ -369,7 +370,7 @@ impl service::users::Data for KeyValueDatabase {
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &DeviceId, device_id: &DeviceId,
one_time_key_key: &DeviceKeyId, one_time_key_key: &OwnedKeyId<OneTimeKeyAlgorithm, OneTimeKeyName>,
one_time_key_value: &Raw<OneTimeKey>, one_time_key_value: &Raw<OneTimeKey>,
) -> Result<()> { ) -> Result<()> {
let mut key = user_id.as_bytes().to_vec(); let mut key = user_id.as_bytes().to_vec();
@ -388,7 +389,7 @@ impl service::users::Data for KeyValueDatabase {
// anymore) // anymore)
key.extend_from_slice( key.extend_from_slice(
serde_json::to_string(one_time_key_key) serde_json::to_string(one_time_key_key)
.expect("DeviceKeyId::to_string always works") .expect("OwnedKeyId::to_string always works")
.as_bytes(), .as_bytes(),
); );
@ -410,8 +411,8 @@ impl service::users::Data for KeyValueDatabase {
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &DeviceId, device_id: &DeviceId,
key_algorithm: &DeviceKeyAlgorithm, key_algorithm: &OneTimeKeyAlgorithm,
) -> Result<Option<(OwnedDeviceKeyId, Raw<OneTimeKey>)>> { ) -> Result<Option<(OwnedOneTimeKeyId, Raw<OneTimeKey>)>> {
let mut prefix = user_id.as_bytes().to_vec(); let mut prefix = user_id.as_bytes().to_vec();
prefix.push(0xFF); prefix.push(0xFF);
prefix.extend_from_slice(device_id.as_bytes()); prefix.extend_from_slice(device_id.as_bytes());
@ -455,7 +456,7 @@ impl service::users::Data for KeyValueDatabase {
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &DeviceId, device_id: &DeviceId,
) -> Result<BTreeMap<DeviceKeyAlgorithm, UInt>> { ) -> Result<BTreeMap<OneTimeKeyAlgorithm, UInt>> {
let mut userdeviceid = user_id.as_bytes().to_vec(); let mut userdeviceid = user_id.as_bytes().to_vec();
userdeviceid.push(0xFF); userdeviceid.push(0xFF);
userdeviceid.extend_from_slice(device_id.as_bytes()); userdeviceid.extend_from_slice(device_id.as_bytes());
@ -467,7 +468,7 @@ impl service::users::Data for KeyValueDatabase {
.scan_prefix(userdeviceid) .scan_prefix(userdeviceid)
.map(|(bytes, _)| { .map(|(bytes, _)| {
Ok::<_, Error>( Ok::<_, Error>(
serde_json::from_slice::<OwnedDeviceKeyId>( serde_json::from_slice::<OwnedOneTimeKeyId>(
bytes.rsplit(|&b| b == 0xFF).next().ok_or_else( bytes.rsplit(|&b| b == 0xFF).next().ok_or_else(
|| { || {
Error::bad_database( Error::bad_database(

View file

@ -16,8 +16,8 @@ use ruma::{
encryption::{CrossSigningKey, DeviceKeys, OneTimeKey}, encryption::{CrossSigningKey, DeviceKeys, OneTimeKey},
events::AnyToDeviceEvent, events::AnyToDeviceEvent,
serde::Raw, serde::Raw,
DeviceId, DeviceKeyAlgorithm, DeviceKeyId, OwnedDeviceId, OwnedDeviceKeyId, DeviceId, OneTimeKeyAlgorithm, OneTimeKeyName, OwnedDeviceId, OwnedKeyId,
OwnedMxcUri, OwnedRoomId, OwnedUserId, UInt, UserId, OwnedMxcUri, OwnedOneTimeKeyId, OwnedRoomId, OwnedUserId, UInt, UserId,
}; };
use crate::{services, Error, Result}; use crate::{services, Error, Result};
@ -423,7 +423,7 @@ impl Service {
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &DeviceId, device_id: &DeviceId,
one_time_key_key: &DeviceKeyId, one_time_key_key: &OwnedKeyId<OneTimeKeyAlgorithm, OneTimeKeyName>,
one_time_key_value: &Raw<OneTimeKey>, one_time_key_value: &Raw<OneTimeKey>,
) -> Result<()> { ) -> Result<()> {
self.db.add_one_time_key( self.db.add_one_time_key(
@ -438,8 +438,8 @@ impl Service {
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &DeviceId, device_id: &DeviceId,
key_algorithm: &DeviceKeyAlgorithm, key_algorithm: &OneTimeKeyAlgorithm,
) -> Result<Option<(OwnedDeviceKeyId, Raw<OneTimeKey>)>> { ) -> Result<Option<(OwnedOneTimeKeyId, Raw<OneTimeKey>)>> {
self.db.take_one_time_key(user_id, device_id, key_algorithm) self.db.take_one_time_key(user_id, device_id, key_algorithm)
} }
@ -447,7 +447,7 @@ impl Service {
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &DeviceId, device_id: &DeviceId,
) -> Result<BTreeMap<DeviceKeyAlgorithm, UInt>> { ) -> Result<BTreeMap<OneTimeKeyAlgorithm, UInt>> {
self.db.count_one_time_keys(user_id, device_id) self.db.count_one_time_keys(user_id, device_id)
} }

View file

@ -5,8 +5,8 @@ use ruma::{
encryption::{CrossSigningKey, DeviceKeys, OneTimeKey}, encryption::{CrossSigningKey, DeviceKeys, OneTimeKey},
events::AnyToDeviceEvent, events::AnyToDeviceEvent,
serde::Raw, serde::Raw,
DeviceId, DeviceKeyAlgorithm, DeviceKeyId, OwnedDeviceId, OwnedDeviceKeyId, DeviceId, OneTimeKeyAlgorithm, OneTimeKeyName, OwnedDeviceId, OwnedKeyId,
OwnedMxcUri, OwnedUserId, UInt, UserId, OwnedMxcUri, OwnedOneTimeKeyId, OwnedUserId, UInt, UserId,
}; };
use crate::Result; use crate::Result;
@ -112,7 +112,7 @@ pub(crate) trait Data: Send + Sync {
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &DeviceId, device_id: &DeviceId,
one_time_key_key: &DeviceKeyId, one_time_key_key: &OwnedKeyId<OneTimeKeyAlgorithm, OneTimeKeyName>,
one_time_key_value: &Raw<OneTimeKey>, one_time_key_value: &Raw<OneTimeKey>,
) -> Result<()>; ) -> Result<()>;
@ -120,14 +120,14 @@ pub(crate) trait Data: Send + Sync {
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &DeviceId, device_id: &DeviceId,
key_algorithm: &DeviceKeyAlgorithm, key_algorithm: &OneTimeKeyAlgorithm,
) -> Result<Option<(OwnedDeviceKeyId, Raw<OneTimeKey>)>>; ) -> Result<Option<(OwnedOneTimeKeyId, Raw<OneTimeKey>)>>;
fn count_one_time_keys( fn count_one_time_keys(
&self, &self,
user_id: &UserId, user_id: &UserId,
device_id: &DeviceId, device_id: &DeviceId,
) -> Result<BTreeMap<DeviceKeyAlgorithm, UInt>>; ) -> Result<BTreeMap<OneTimeKeyAlgorithm, UInt>>;
fn add_device_keys( fn add_device_keys(
&self, &self,