Add unstable-synapse-quirks feature for Sessions struct and fields

This commit is contained in:
Devin R 2020-07-15 16:22:10 -04:00
parent 254b24fb20
commit 101b8689a5
8 changed files with 43 additions and 27 deletions

View File

@ -34,4 +34,14 @@ tasks:
cargo test --all-features --verbose cargo test --all-features --verbose
id_test_2_exit=$? id_test_2_exit=$?
# ruma-client_api also has a few features. Make sure it works both with
# all of them and none of them being enabled.
cd ruma-client-api
cargo test --no-default-features --verbose
id_test_1_exit=$?
cargo test --all-features --verbose
id_test_2_exit=$?
exit $(( $fmt_exit || $clippy_exit || $test_exit || $id_test_1_exit || $id_test_2_exit )) exit $(( $fmt_exit || $clippy_exit || $test_exit || $id_test_1_exit || $id_test_2_exit ))

View File

@ -34,6 +34,16 @@ tasks:
cargo test --all-features --verbose cargo test --all-features --verbose
id_test_2_exit=$? id_test_2_exit=$?
# ruma-client_api also has a few features. Make sure it works both with
# all of them and none of them being enabled.
cd ruma-client-api
cargo test --no-default-features --verbose
id_test_1_exit=$?
cargo test --all-features --verbose
id_test_2_exit=$?
exit $(( $fmt_exit || $clippy_exit || $test_exit || $id_test_1_exit || $id_test_2_exit )) exit $(( $fmt_exit || $clippy_exit || $test_exit || $id_test_1_exit || $id_test_2_exit ))
# TODO: Add audit task once cargo-audit binary releases are available. # TODO: Add audit task once cargo-audit binary releases are available.
# See https://github.com/RustSec/cargo-audit/issues/66 # See https://github.com/RustSec/cargo-audit/issues/66

View File

@ -34,3 +34,4 @@ matches = "0.1.8"
[features] [features]
unstable-pre-spec = [] unstable-pre-spec = []
unstable-synapse-quirks = []

View File

@ -3,7 +3,6 @@
pub mod account; pub mod account;
pub mod alias; pub mod alias;
pub mod appservice; pub mod appservice;
#[cfg(feature = "unstable-pre-spec")]
pub mod backup; pub mod backup;
pub mod capabilities; pub mod capabilities;
pub mod config; pub mod config;

View File

@ -14,6 +14,15 @@ use std::collections::BTreeMap;
use crate::r0::keys::AlgorithmAndDeviceId; use crate::r0::keys::AlgorithmAndDeviceId;
// TODO: remove
/// A wrapper around a mapping of session IDs to key data.
#[cfg(feature = "unstable-synapse-quirks")]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Sessions {
/// A map of session IDs to key data.
pub sessions: BTreeMap<String, KeyData>,
}
/// The algorithm used for storing backups. /// The algorithm used for storing backups.
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(tag = "algorithm", content = "auth_data")] #[serde(tag = "algorithm", content = "auth_data")]

View File

@ -5,9 +5,6 @@ use std::collections::BTreeMap;
use js_int::UInt; use js_int::UInt;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::RoomId; use ruma_identifiers::RoomId;
use serde::{Deserialize, Serialize};
use super::KeyData;
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -27,7 +24,12 @@ ruma_api! {
/// A map from room IDs to session IDs to key data. /// A map from room IDs to session IDs to key data.
/// ///
/// Note: synapse has the `sessions: {}` wrapper, the Matrix spec does not. /// Note: synapse has the `sessions: {}` wrapper, the Matrix spec does not.
pub rooms: BTreeMap<RoomId, Sessions>, #[cfg(feature = "unstable-synapse-quirks")]
pub rooms: BTreeMap<RoomId, super::Sessions>,
/// A map from room IDs to session IDs to key data.
#[cfg(not(feature = "unstable-synapse-quirks"))]
pub rooms: BTreeMap<RoomId, BTreeMap<String, super::KeyData>>,
} }
response: { response: {
@ -41,12 +43,3 @@ ruma_api! {
error: crate::Error error: crate::Error
} }
// TODO: remove
/// A wrapper around a mapping of session IDs to key data.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Sessions {
// TODO: remove
/// A map of session IDs to key data.
pub sessions: BTreeMap<String, KeyData>,
}

View File

@ -4,9 +4,6 @@ use std::collections::BTreeMap;
use ruma_api::ruma_api; use ruma_api::ruma_api;
use ruma_identifiers::RoomId; use ruma_identifiers::RoomId;
use serde::{Deserialize, Serialize};
use super::KeyData;
ruma_api! { ruma_api! {
metadata: { metadata: {
@ -28,17 +25,13 @@ ruma_api! {
/// A map from room IDs to session IDs to key data. /// A map from room IDs to session IDs to key data.
/// ///
/// Note: synapse has the `sessions: {}` wrapper, the Matrix spec does not. /// Note: synapse has the `sessions: {}` wrapper, the Matrix spec does not.
pub rooms: BTreeMap<RoomId, Sessions>, #[cfg(feature = "unstable-synapse-quirks")]
pub rooms: BTreeMap<RoomId, super::Sessions>,
/// A map from room IDs to session IDs to key data.
#[cfg(not(feature = "unstable-synapse-quirks"))]
pub rooms: BTreeMap<RoomId, BTreeMap<String, super::KeyData>>,
} }
error: crate::Error error: crate::Error
} }
// TODO: remove
/// A wrapper around a mapping of session IDs to key data.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Sessions {
// TODO: remove
/// A map of session IDs to key data.
pub sessions: BTreeMap<String, KeyData>,
}

View File

@ -16,6 +16,7 @@ edition = "2018"
either = ["ruma-identifiers/either"] either = ["ruma-identifiers/either"]
rand = ["ruma-identifiers/rand"] rand = ["ruma-identifiers/rand"]
unstable-pre-spec = ["ruma-client-api/unstable-pre-spec"] unstable-pre-spec = ["ruma-client-api/unstable-pre-spec"]
unstable-synapse-quirks = ["ruma-client-api/unstable-synapse-quirks"]
appservice-api = ["ruma-api", "ruma-appservice-api", "ruma-events"] appservice-api = ["ruma-api", "ruma-appservice-api", "ruma-events"]
client-api = ["ruma-api", "ruma-client-api", "ruma-events"] client-api = ["ruma-api", "ruma-client-api", "ruma-events"]