1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-06-27 16:35:59 +00:00

chore: upgrade ruma

This commit is contained in:
Matthias Ahouansou 2025-02-23 05:35:28 +00:00
parent 406367b4f2
commit 2a7aa6242f
No known key found for this signature in database
14 changed files with 143 additions and 144 deletions

2
.cargo/config.toml Normal file
View file

@ -0,0 +1,2 @@
[build]
rustflags = ["--cfg=ruma_unstable_exhaustive_types"]

124
Cargo.lock generated
View file

@ -528,7 +528,7 @@ dependencies = [
"serde_json", "serde_json",
"serde_yaml", "serde_yaml",
"sha-1", "sha-1",
"thiserror", "thiserror 1.0.61",
"thread_local", "thread_local",
"threadpool", "threadpool",
"tikv-jemallocator", "tikv-jemallocator",
@ -1062,7 +1062,7 @@ dependencies = [
"ipnet", "ipnet",
"once_cell", "once_cell",
"rand", "rand",
"thiserror", "thiserror 1.0.61",
"tinyvec", "tinyvec",
"tokio", "tokio",
"tracing", "tracing",
@ -1085,7 +1085,7 @@ dependencies = [
"rand", "rand",
"resolv-conf", "resolv-conf",
"smallvec", "smallvec",
"thiserror", "thiserror 1.0.61",
"tokio", "tokio",
"tracing", "tracing",
] ]
@ -1723,7 +1723,7 @@ dependencies = [
"js-sys", "js-sys",
"once_cell", "once_cell",
"pin-project-lite", "pin-project-lite",
"thiserror", "thiserror 1.0.61",
"urlencoding", "urlencoding",
] ]
@ -1750,7 +1750,7 @@ dependencies = [
"opentelemetry-semantic-conventions", "opentelemetry-semantic-conventions",
"opentelemetry_sdk", "opentelemetry_sdk",
"prost", "prost",
"thiserror", "thiserror 1.0.61",
"tokio", "tokio",
"tonic", "tonic",
] ]
@ -1790,7 +1790,7 @@ dependencies = [
"ordered-float", "ordered-float",
"percent-encoding", "percent-encoding",
"rand", "rand",
"thiserror", "thiserror 1.0.61",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
] ]
@ -1968,9 +1968,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.85" version = "1.0.93"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@ -2073,7 +2073,7 @@ checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891"
dependencies = [ dependencies = [
"getrandom", "getrandom",
"libredox", "libredox",
"thiserror", "thiserror 1.0.61",
] ]
[[package]] [[package]]
@ -2189,8 +2189,8 @@ dependencies = [
[[package]] [[package]]
name = "ruma" name = "ruma"
version = "0.10.1" version = "0.12.1"
source = "git+https://github.com/ruma/ruma#c06af4385e0e30c48a8e9ca3d488da32102d0db9" source = "git+https://github.com/ruma/ruma.git#afaf132362fe6195556a872351a70337e97ab755"
dependencies = [ dependencies = [
"assign", "assign",
"js_int", "js_int",
@ -2200,7 +2200,6 @@ dependencies = [
"ruma-common", "ruma-common",
"ruma-events", "ruma-events",
"ruma-federation-api", "ruma-federation-api",
"ruma-identity-service-api",
"ruma-push-gateway-api", "ruma-push-gateway-api",
"ruma-server-util", "ruma-server-util",
"ruma-signatures", "ruma-signatures",
@ -2210,8 +2209,8 @@ dependencies = [
[[package]] [[package]]
name = "ruma-appservice-api" name = "ruma-appservice-api"
version = "0.10.0" version = "0.12.1"
source = "git+https://github.com/ruma/ruma#c06af4385e0e30c48a8e9ca3d488da32102d0db9" source = "git+https://github.com/ruma/ruma.git#afaf132362fe6195556a872351a70337e97ab755"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -2222,8 +2221,8 @@ dependencies = [
[[package]] [[package]]
name = "ruma-client-api" name = "ruma-client-api"
version = "0.18.0" version = "0.20.1"
source = "git+https://github.com/ruma/ruma#c06af4385e0e30c48a8e9ca3d488da32102d0db9" source = "git+https://github.com/ruma/ruma.git#afaf132362fe6195556a872351a70337e97ab755"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"assign", "assign",
@ -2238,20 +2237,21 @@ dependencies = [
"serde", "serde",
"serde_html_form", "serde_html_form",
"serde_json", "serde_json",
"thiserror", "thiserror 2.0.11",
"url", "url",
"web-time", "web-time",
] ]
[[package]] [[package]]
name = "ruma-common" name = "ruma-common"
version = "0.13.0" version = "0.15.1"
source = "git+https://github.com/ruma/ruma#c06af4385e0e30c48a8e9ca3d488da32102d0db9" source = "git+https://github.com/ruma/ruma.git#afaf132362fe6195556a872351a70337e97ab755"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"base64 0.22.1", "base64 0.22.1",
"bytes", "bytes",
"form_urlencoded", "form_urlencoded",
"getrandom",
"http 1.1.0", "http 1.1.0",
"indexmap 2.2.6", "indexmap 2.2.6",
"js_int", "js_int",
@ -2264,7 +2264,7 @@ dependencies = [
"serde", "serde",
"serde_html_form", "serde_html_form",
"serde_json", "serde_json",
"thiserror", "thiserror 2.0.11",
"time", "time",
"tracing", "tracing",
"url", "url",
@ -2275,8 +2275,8 @@ dependencies = [
[[package]] [[package]]
name = "ruma-events" name = "ruma-events"
version = "0.28.1" version = "0.30.1"
source = "git+https://github.com/ruma/ruma#c06af4385e0e30c48a8e9ca3d488da32102d0db9" source = "git+https://github.com/ruma/ruma.git#afaf132362fe6195556a872351a70337e97ab755"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"indexmap 2.2.6", "indexmap 2.2.6",
@ -2289,7 +2289,7 @@ dependencies = [
"ruma-macros", "ruma-macros",
"serde", "serde",
"serde_json", "serde_json",
"thiserror", "thiserror 2.0.11",
"tracing", "tracing",
"url", "url",
"web-time", "web-time",
@ -2298,8 +2298,8 @@ dependencies = [
[[package]] [[package]]
name = "ruma-federation-api" name = "ruma-federation-api"
version = "0.9.0" version = "0.11.0"
source = "git+https://github.com/ruma/ruma#c06af4385e0e30c48a8e9ca3d488da32102d0db9" source = "git+https://github.com/ruma/ruma.git#afaf132362fe6195556a872351a70337e97ab755"
dependencies = [ dependencies = [
"bytes", "bytes",
"http 1.1.0", "http 1.1.0",
@ -2316,30 +2316,19 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers-validation" name = "ruma-identifiers-validation"
version = "0.9.5" version = "0.10.1"
source = "git+https://github.com/ruma/ruma#c06af4385e0e30c48a8e9ca3d488da32102d0db9" source = "git+https://github.com/ruma/ruma.git#afaf132362fe6195556a872351a70337e97ab755"
dependencies = [ dependencies = [
"js_int", "js_int",
"thiserror", "thiserror 2.0.11",
]
[[package]]
name = "ruma-identity-service-api"
version = "0.9.0"
source = "git+https://github.com/ruma/ruma#c06af4385e0e30c48a8e9ca3d488da32102d0db9"
dependencies = [
"js_int",
"ruma-common",
"serde",
] ]
[[package]] [[package]]
name = "ruma-macros" name = "ruma-macros"
version = "0.13.0" version = "0.15.1"
source = "git+https://github.com/ruma/ruma#c06af4385e0e30c48a8e9ca3d488da32102d0db9" source = "git+https://github.com/ruma/ruma.git#afaf132362fe6195556a872351a70337e97ab755"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"once_cell",
"proc-macro-crate", "proc-macro-crate",
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2351,8 +2340,8 @@ dependencies = [
[[package]] [[package]]
name = "ruma-push-gateway-api" name = "ruma-push-gateway-api"
version = "0.9.0" version = "0.11.0"
source = "git+https://github.com/ruma/ruma#c06af4385e0e30c48a8e9ca3d488da32102d0db9" source = "git+https://github.com/ruma/ruma.git#afaf132362fe6195556a872351a70337e97ab755"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -2363,21 +2352,21 @@ dependencies = [
[[package]] [[package]]
name = "ruma-server-util" name = "ruma-server-util"
version = "0.3.0" version = "0.5.0"
source = "git+https://github.com/ruma/ruma#c06af4385e0e30c48a8e9ca3d488da32102d0db9" source = "git+https://github.com/ruma/ruma.git#afaf132362fe6195556a872351a70337e97ab755"
dependencies = [ dependencies = [
"headers", "headers",
"http 1.1.0", "http 1.1.0",
"http-auth", "http-auth",
"ruma-common", "ruma-common",
"thiserror", "thiserror 2.0.11",
"tracing", "tracing",
] ]
[[package]] [[package]]
name = "ruma-signatures" name = "ruma-signatures"
version = "0.15.0" version = "0.17.0"
source = "git+https://github.com/ruma/ruma#c06af4385e0e30c48a8e9ca3d488da32102d0db9" source = "git+https://github.com/ruma/ruma.git#afaf132362fe6195556a872351a70337e97ab755"
dependencies = [ dependencies = [
"base64 0.22.1", "base64 0.22.1",
"ed25519-dalek", "ed25519-dalek",
@ -2387,21 +2376,20 @@ dependencies = [
"serde_json", "serde_json",
"sha2", "sha2",
"subslice", "subslice",
"thiserror", "thiserror 2.0.11",
] ]
[[package]] [[package]]
name = "ruma-state-res" name = "ruma-state-res"
version = "0.11.0" version = "0.13.0"
source = "git+https://github.com/ruma/ruma#c06af4385e0e30c48a8e9ca3d488da32102d0db9" source = "git+https://github.com/ruma/ruma.git#afaf132362fe6195556a872351a70337e97ab755"
dependencies = [ dependencies = [
"itertools",
"js_int", "js_int",
"ruma-common", "ruma-common",
"ruma-events", "ruma-events",
"serde", "serde",
"serde_json", "serde_json",
"thiserror", "thiserror 2.0.11",
"tracing", "tracing",
] ]
@ -2793,7 +2781,7 @@ checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085"
dependencies = [ dependencies = [
"num-bigint", "num-bigint",
"num-traits", "num-traits",
"thiserror", "thiserror 1.0.61",
"time", "time",
] ]
@ -2855,9 +2843,9 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.66" version = "2.0.98"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2882,7 +2870,16 @@ version = "1.0.61"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl 1.0.61",
]
[[package]]
name = "thiserror"
version = "2.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc"
dependencies = [
"thiserror-impl 2.0.11",
] ]
[[package]] [[package]]
@ -2896,6 +2893,17 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "thiserror-impl"
version = "2.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "thread_local" name = "thread_local"
version = "1.1.8" version = "1.1.8"
@ -3049,7 +3057,7 @@ checksum = "51165dfa029d2a65969413a6cc96f354b86b464498702f174a4efa13608fd8c0"
dependencies = [ dependencies = [
"either", "either",
"futures-util", "futures-util",
"thiserror", "thiserror 1.0.61",
"tokio", "tokio",
] ]

View file

@ -147,19 +147,25 @@ sd-notify = { version = "0.4.1", optional = true }
features = [ features = [
"appservice-api-c", "appservice-api-c",
"client-api", "client-api",
"compat", "compat-empty-string-null",
"compat-get-3pids",
"compat-null",
"compat-optional",
"compat-optional-txn-pdus",
"compat-server-signing-key-version",
"compat-signature-id",
"compat-tag-info",
"compat-unset-avatar",
"federation-api", "federation-api",
"push-gateway-api-c", "push-gateway-api-c",
"rand", "rand",
"ring-compat", "ring-compat",
"server-util", "server-util",
"state-res", "state-res",
"unstable-exhaustive-types",
"unstable-msc2448", "unstable-msc2448",
"unstable-msc3575", "unstable-msc3575",
"unstable-unspecified",
] ]
git = "https://github.com/ruma/ruma" git = "https://github.com/ruma/ruma.git"
[dependencies.rocksdb] [dependencies.rocksdb]
features = ["lz4", "multi-threaded-cf", "zstd"] features = ["lz4", "multi-threaded-cf", "zstd"]

View file

@ -52,6 +52,7 @@ let
# Keep sorted # Keep sorted
include = [ include = [
".cargo"
"Cargo.lock" "Cargo.lock"
"Cargo.toml" "Cargo.toml"
"src" "src"

View file

@ -14,7 +14,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 std::{ use std::{
@ -465,7 +465,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<OwnedUserId, BTreeMap<OwnedDeviceId, DeviceKeyAlgorithm>>, one_time_keys_input: &BTreeMap<OwnedUserId, 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

@ -301,7 +301,11 @@ async fn get_content_as_filename(
pub async fn get_content_thumbnail_route( pub async fn get_content_thumbnail_route(
body: Ruma<media::get_content_thumbnail::v3::Request>, body: Ruma<media::get_content_thumbnail::v3::Request>,
) -> Result<media::get_content_thumbnail::v3::Response> { ) -> Result<media::get_content_thumbnail::v3::Response> {
let get_content_thumbnail::v1::Response { file, content_type } = get_content_thumbnail( let get_content_thumbnail::v1::Response {
file,
content_type,
content_disposition,
} = get_content_thumbnail(
&body.server_name, &body.server_name,
body.media_id.clone(), body.media_id.clone(),
body.height, body.height,
@ -316,6 +320,7 @@ pub async fn get_content_thumbnail_route(
file, file,
content_type, content_type,
cross_origin_resource_policy: Some("cross-origin".to_owned()), cross_origin_resource_policy: Some("cross-origin".to_owned()),
content_disposition,
}) })
} }
@ -349,7 +354,9 @@ async fn get_content_thumbnail(
let mxc = format!("mxc://{}/{}", server_name, media_id); let mxc = format!("mxc://{}/{}", server_name, media_id);
if let Some(FileMeta { if let Some(FileMeta {
file, content_type, .. file,
content_type,
content_disposition,
}) = services() }) = services()
.media .media
.get_thumbnail( .get_thumbnail(
@ -363,7 +370,11 @@ async fn get_content_thumbnail(
) )
.await? .await?
{ {
Ok(get_content_thumbnail::v1::Response { file, content_type }) Ok(get_content_thumbnail::v1::Response {
file,
content_type,
content_disposition: Some(content_disposition),
})
} else if server_name != services().globals.server_name() && allow_remote { } else if server_name != services().globals.server_name() && allow_remote {
let thumbnail_response = match services() let thumbnail_response = match services()
.sending .sending
@ -386,6 +397,7 @@ async fn get_content_thumbnail(
}) => get_content_thumbnail::v1::Response { }) => get_content_thumbnail::v1::Response {
file: content.file, file: content.file,
content_type: content.content_type, content_type: content.content_type,
content_disposition: content.content_disposition,
}, },
Ok(federation_media::get_content_thumbnail::v1::Response { Ok(federation_media::get_content_thumbnail::v1::Response {
@ -393,14 +405,23 @@ async fn get_content_thumbnail(
content: FileOrLocation::Location(url), content: FileOrLocation::Location(url),
}) => { }) => {
let get_content::v1::Response { let get_content::v1::Response {
file, content_type, .. file,
content_type,
content_disposition,
} = get_location_content(url).await?; } = get_location_content(url).await?;
get_content_thumbnail::v1::Response { file, content_type } get_content_thumbnail::v1::Response {
file,
content_type,
content_disposition,
}
} }
Err(Error::BadRequest(ErrorKind::Unrecognized, _)) => { Err(Error::BadRequest(ErrorKind::Unrecognized, _)) => {
let media::get_content_thumbnail::v3::Response { let media::get_content_thumbnail::v3::Response {
file, content_type, .. file,
content_type,
content_disposition,
..
} = services() } = services()
.sending .sending
.send_federation_request( .send_federation_request(
@ -419,7 +440,11 @@ async fn get_content_thumbnail(
) )
.await?; .await?;
get_content_thumbnail::v1::Response { file, content_type } get_content_thumbnail::v1::Response {
file,
content_type,
content_disposition,
}
} }
Err(e) => return Err(e), Err(e) => return Err(e),
}; };

View file

@ -5,7 +5,7 @@ use ruma::{
push::{ push::{
delete_pushrule, get_pushers, get_pushrule, get_pushrule_actions, get_pushrule_enabled, delete_pushrule, get_pushers, get_pushrule, get_pushrule_actions, get_pushrule_enabled,
get_pushrules_all, set_pusher, set_pushrule, set_pushrule_actions, get_pushrules_all, set_pusher, set_pushrule, set_pushrule_actions,
set_pushrule_enabled, RuleScope, set_pushrule_enabled,
}, },
}, },
events::{push_rules::PushRulesEvent, GlobalAccountDataEventType}, events::{push_rules::PushRulesEvent, GlobalAccountDataEventType},
@ -89,13 +89,6 @@ pub 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(
@ -161,13 +154,6 @@ pub async fn get_pushrule_actions_route(
) -> Result<get_pushrule_actions::v3::Response> { ) -> Result<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(
@ -204,13 +190,6 @@ pub async fn set_pushrule_actions_route(
) -> Result<set_pushrule_actions::v3::Response> { ) -> Result<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(
@ -256,13 +235,6 @@ pub async fn get_pushrule_enabled_route(
) -> Result<get_pushrule_enabled::v3::Response> { ) -> Result<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(
@ -298,13 +270,6 @@ pub async fn set_pushrule_enabled_route(
) -> Result<set_pushrule_enabled::v3::Response> { ) -> Result<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(
@ -350,13 +315,6 @@ pub async fn delete_pushrule_route(
) -> Result<delete_pushrule::v3::Response> { ) -> Result<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

@ -56,7 +56,7 @@ use ruma::{
to_device::DeviceIdOrAllDevices, to_device::DeviceIdOrAllDevices,
uint, user_id, CanonicalJsonObject, CanonicalJsonValue, EventId, MilliSecondsSinceUnixEpoch, uint, user_id, CanonicalJsonObject, CanonicalJsonValue, EventId, MilliSecondsSinceUnixEpoch,
OwnedEventId, OwnedRoomId, OwnedServerName, OwnedServerSigningKeyId, OwnedUserId, RoomId, OwnedEventId, OwnedRoomId, OwnedServerName, OwnedServerSigningKeyId, 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 std::{ use std::{
@ -714,7 +714,7 @@ pub 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: BTreeMap::new(), old_verify_keys: BTreeMap::new(),
signatures: BTreeMap::new(), signatures: Signatures::new(),
valid_until_ts: MilliSecondsSinceUnixEpoch::from_system_time( valid_until_ts: MilliSecondsSinceUnixEpoch::from_system_time(
SystemTime::now() + Duration::from_secs(86400 * 7), SystemTime::now() + Duration::from_secs(86400 * 7),
) )

View file

@ -5,8 +5,8 @@ use ruma::{
encryption::{CrossSigningKey, DeviceKeys, OneTimeKey}, encryption::{CrossSigningKey, DeviceKeys, OneTimeKey},
events::{AnyToDeviceEvent, StateEventType}, events::{AnyToDeviceEvent, StateEventType},
serde::Raw, serde::Raw,
DeviceId, DeviceKeyAlgorithm, DeviceKeyId, MilliSecondsSinceUnixEpoch, OwnedDeviceId, DeviceId, MilliSecondsSinceUnixEpoch, OneTimeKeyAlgorithm, OwnedDeviceId, OwnedMxcUri,
OwnedDeviceKeyId, OwnedMxcUri, OwnedUserId, UInt, UserId, OwnedOneTimeKeyId, OwnedUserId, UInt, UserId,
}; };
use tracing::warn; use tracing::warn;
@ -308,7 +308,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: &OwnedOneTimeKeyId,
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();
@ -356,8 +356,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());
@ -395,7 +395,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());
@ -406,15 +406,12 @@ impl service::users::Data for KeyValueDatabase {
self.onetimekeyid_onetimekeys self.onetimekeyid_onetimekeys
.scan_prefix(userdeviceid) .scan_prefix(userdeviceid)
.map(|(bytes, _)| { .map(|(bytes, _)| {
Ok::<_, Error>( serde_json::from_slice::<OneTimeKeyAlgorithm>(
serde_json::from_slice::<OwnedDeviceKeyId>(
bytes.rsplit(|&b| b == 0xff).next().ok_or_else(|| { bytes.rsplit(|&b| b == 0xff).next().ok_or_else(|| {
Error::bad_database("OneTimeKey ID in db is invalid.") Error::bad_database("OneTimeKey ID in db is invalid.")
})?, })?,
) )
.map_err(|_| Error::bad_database("DeviceKeyId in db is invalid."))? .map_err(|_| Error::bad_database("DeviceKeyId in db is invalid."))
.algorithm(),
)
}) })
{ {
*counts.entry(algorithm?).or_default() += UInt::from(1_u32); *counts.entry(algorithm?).or_default() += UInt::from(1_u32);

View file

@ -230,7 +230,7 @@ impl Service {
let event_id_only = http.format == Some(PushFormat::EventIdOnly); let event_id_only = http.format == Some(PushFormat::EventIdOnly);
let mut device = Device::new(pusher.ids.app_id.clone(), pusher.ids.pushkey.clone()); let mut device = Device::new(pusher.ids.app_id.clone(), pusher.ids.pushkey.clone());
device.data.default_payload = http.default_payload.clone(); device.data.data = http.data.clone();
device.data.format.clone_from(&http.format); device.data.format.clone_from(&http.format);
// Tweaks are only added if the format is NOT event_id_only // Tweaks are only added if the format is NOT event_id_only

View file

@ -498,6 +498,8 @@ impl Service {
) )
})?, })?,
appservice::event::push_events::v1::Request { appservice::event::push_events::v1::Request {
//TODO: ephemeral pushing
ephemeral: Vec::new(),
events: pdu_jsons, events: pdu_jsons,
txn_id: (&*general_purpose::URL_SAFE_NO_PAD.encode(calculate_hash( txn_id: (&*general_purpose::URL_SAFE_NO_PAD.encode(calculate_hash(
&events &events

View file

@ -4,8 +4,8 @@ use ruma::{
encryption::{CrossSigningKey, DeviceKeys, OneTimeKey}, encryption::{CrossSigningKey, DeviceKeys, OneTimeKey},
events::AnyToDeviceEvent, events::AnyToDeviceEvent,
serde::Raw, serde::Raw,
DeviceId, DeviceKeyAlgorithm, DeviceKeyId, OwnedDeviceId, OwnedDeviceKeyId, OwnedMxcUri, DeviceId, OneTimeKeyAlgorithm, OwnedDeviceId, OwnedMxcUri, OwnedOneTimeKeyId, OwnedUserId,
OwnedUserId, UInt, UserId, UInt, UserId,
}; };
use std::collections::BTreeMap; use std::collections::BTreeMap;
@ -79,7 +79,7 @@ pub 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: &OwnedOneTimeKeyId,
one_time_key_value: &Raw<OneTimeKey>, one_time_key_value: &Raw<OneTimeKey>,
) -> Result<()>; ) -> Result<()>;
@ -89,14 +89,14 @@ pub 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,

View file

@ -18,8 +18,8 @@ use ruma::{
encryption::{CrossSigningKey, DeviceKeys, OneTimeKey}, encryption::{CrossSigningKey, DeviceKeys, OneTimeKey},
events::AnyToDeviceEvent, events::AnyToDeviceEvent,
serde::Raw, serde::Raw,
DeviceId, DeviceKeyAlgorithm, DeviceKeyId, OwnedDeviceId, OwnedDeviceKeyId, OwnedMxcUri, DeviceId, OneTimeKeyAlgorithm, OwnedDeviceId, OwnedMxcUri, OwnedOneTimeKeyId, OwnedRoomId,
OwnedRoomId, OwnedUserId, UInt, UserId, OwnedUserId, UInt, UserId,
}; };
use crate::{services, Error, Result}; use crate::{services, Error, Result};
@ -373,7 +373,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: &OwnedOneTimeKeyId,
one_time_key_value: &Raw<OneTimeKey>, one_time_key_value: &Raw<OneTimeKey>,
) -> Result<()> { ) -> Result<()> {
self.db self.db
@ -388,8 +388,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)
} }
@ -397,7 +397,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

@ -60,7 +60,7 @@ pub enum Error {
BadDatabase(&'static str), BadDatabase(&'static str),
#[error("uiaa")] #[error("uiaa")]
Uiaa(UiaaInfo), Uiaa(UiaaInfo),
#[error("{0}: {1}")] #[error("{}: {1}",.0.errcode())]
BadRequest(ErrorKind, &'static str), BadRequest(ErrorKind, &'static str),
#[error("{0}")] #[error("{0}")]
Conflict(&'static str), // This is only needed for when a room alias already exists Conflict(&'static str), // This is only needed for when a room alias already exists