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

View file

@ -17,7 +17,7 @@ use ruma::{
federation,
},
serde::Raw,
DeviceKeyAlgorithm, OwnedDeviceId, OwnedUserId, UserId,
OneTimeKeyAlgorithm, OwnedDeviceId, OwnedUserId, UserId,
};
use serde_json::json;
use tracing::debug;
@ -474,7 +474,16 @@ pub(crate) async fn get_keys_helper<F: Fn(&UserId) -> bool>(
let (_, our_master_key) = services()
.users
.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)
.expect("to_value always works");
@ -525,7 +534,7 @@ fn add_unsigned_device_display_name(
pub(crate) async fn claim_keys_helper(
one_time_keys_input: &BTreeMap<
OwnedUserId,
BTreeMap<OwnedDeviceId, DeviceKeyAlgorithm>,
BTreeMap<OwnedDeviceId, OneTimeKeyAlgorithm>,
>,
) -> Result<claim_keys::v3::Response> {
let mut one_time_keys = BTreeMap::new();

View file

@ -670,11 +670,13 @@ pub(crate) async fn get_content_thumbnail_legacy_route(
AmResponse {
file,
content_type,
..
}: AmResponse,
) -> LegacyResponse {
LegacyResponse {
file,
content_type,
content_disposition: None,
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 {
file,
content_type,
content_disposition: None,
}
};

View file

@ -4,7 +4,7 @@ use ruma::{
push::{
delete_pushrule, get_pushers, get_pushrule, get_pushrule_actions,
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},
@ -89,13 +89,6 @@ pub(crate) async fn set_pushrule_route(
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
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()
.account_data
.get(
@ -168,13 +161,6 @@ pub(crate) async fn get_pushrule_actions_route(
) -> Result<Ra<get_pushrule_actions::v3::Response>> {
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()
.account_data
.get(
@ -213,13 +199,6 @@ pub(crate) async fn set_pushrule_actions_route(
) -> Result<Ra<set_pushrule_actions::v3::Response>> {
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()
.account_data
.get(
@ -268,13 +247,6 @@ pub(crate) async fn get_pushrule_enabled_route(
) -> Result<Ra<get_pushrule_enabled::v3::Response>> {
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()
.account_data
.get(
@ -314,13 +286,6 @@ pub(crate) async fn set_pushrule_enabled_route(
) -> Result<Ra<set_pushrule_enabled::v3::Response>> {
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()
.account_data
.get(
@ -369,13 +334,6 @@ pub(crate) async fn delete_pushrule_route(
) -> Result<Ra<delete_pushrule::v3::Response>> {
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()
.account_data
.get(

View file

@ -59,7 +59,7 @@ use ruma::{
uint, user_id, CanonicalJsonObject, CanonicalJsonValue, EventId,
MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedServerName,
OwnedServerSigningKeyId, OwnedSigningKeyId, OwnedUserId, RoomId,
ServerName,
ServerName, Signatures,
};
use serde_json::value::{to_raw_value, RawValue as RawJsonValue};
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(),
verify_keys,
old_verify_keys,
signatures: BTreeMap::new(),
signatures: Signatures::new(),
valid_until_ts: keys.valid_until_ts,
})
.expect("static conversion, no errors"),

View file

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

View file

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

View file

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