client-api: Remove unstable-synapse-quirks from key backups
The spec has been adjusted to follow Synapse.
This commit is contained in:
parent
00121bdb4b
commit
c769d9602d
@ -17,27 +17,15 @@ pub mod get_latest_backup;
|
||||
pub mod update_backup;
|
||||
|
||||
use js_int::UInt;
|
||||
use ruma_identifiers::{DeviceKeyId, RoomId, UserId};
|
||||
use ruma_identifiers::{DeviceKeyId, UserId};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
/// A map from room IDs to session IDs to key data.
|
||||
///
|
||||
/// Note: synapse has the `sessions: {}` wrapper, the Matrix spec does not.
|
||||
#[cfg(not(feature = "unstable-synapse-quirks"))]
|
||||
pub type Rooms = BTreeMap<RoomId, BTreeMap<String, KeyData>>;
|
||||
|
||||
/// A map from room IDs to session IDs to key data.
|
||||
#[cfg(feature = "unstable-synapse-quirks")]
|
||||
pub type Rooms = BTreeMap<RoomId, Sessions>;
|
||||
|
||||
// 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 {
|
||||
pub struct RoomKeyBackup {
|
||||
/// A map of session IDs to key data.
|
||||
pub sessions: BTreeMap<String, KeyData>,
|
||||
pub sessions: BTreeMap<String, KeyBackupData>,
|
||||
}
|
||||
|
||||
/// The algorithm used for storing backups.
|
||||
@ -57,7 +45,7 @@ pub enum BackupAlgorithm {
|
||||
|
||||
/// Information about the backup key.
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct KeyData {
|
||||
pub struct KeyBackupData {
|
||||
/// The index of the first message in the session that the key can decrypt.
|
||||
pub first_message_index: UInt,
|
||||
|
||||
|
@ -4,7 +4,7 @@ use js_int::UInt;
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::RoomId;
|
||||
|
||||
use super::KeyData;
|
||||
use super::KeyBackupData;
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
@ -31,7 +31,7 @@ ruma_api! {
|
||||
|
||||
/// The key information to backup.
|
||||
#[ruma_api(body)]
|
||||
pub session_data: KeyData,
|
||||
pub session_data: KeyBackupData,
|
||||
}
|
||||
|
||||
response: {
|
||||
@ -52,7 +52,7 @@ impl<'a> Request<'a> {
|
||||
version: &'a str,
|
||||
room_id: &'a RoomId,
|
||||
session_id: &'a str,
|
||||
session_data: KeyData,
|
||||
session_data: KeyBackupData,
|
||||
) -> Self {
|
||||
Self { version, room_id, session_id, session_data }
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ use js_int::UInt;
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::RoomId;
|
||||
|
||||
use super::KeyData;
|
||||
use super::KeyBackupData;
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
@ -28,7 +28,7 @@ ruma_api! {
|
||||
pub room_id: &'a RoomId,
|
||||
|
||||
/// A map from session IDs to key data.
|
||||
pub sessions: BTreeMap<String, KeyData>,
|
||||
pub sessions: BTreeMap<String, KeyBackupData>,
|
||||
}
|
||||
|
||||
response: {
|
||||
@ -45,7 +45,11 @@ ruma_api! {
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
/// Creates a new `Request` with the given version, room_id and sessions.
|
||||
pub fn new(version: &'a str, room_id: &'a RoomId, sessions: BTreeMap<String, KeyData>) -> Self {
|
||||
pub fn new(
|
||||
version: &'a str,
|
||||
room_id: &'a RoomId,
|
||||
sessions: BTreeMap<String, KeyBackupData>,
|
||||
) -> Self {
|
||||
Self { version, room_id, sessions }
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
//! [PUT /_matrix/client/r0/room_keys/keys](https://matrix.org/docs/spec/client_server/unstable#put-matrix-client-r0-room-keys-keys)
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use js_int::UInt;
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::RoomId;
|
||||
|
||||
use super::Rooms;
|
||||
use super::RoomKeyBackup;
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
@ -21,9 +24,7 @@ ruma_api! {
|
||||
pub version: &'a str,
|
||||
|
||||
/// A map from room IDs to session IDs to key data.
|
||||
///
|
||||
/// Note: synapse has the `sessions: {}` wrapper, the Matrix spec does not.
|
||||
pub rooms: Rooms,
|
||||
pub rooms: BTreeMap<RoomId, RoomKeyBackup>,
|
||||
}
|
||||
|
||||
response: {
|
||||
@ -39,8 +40,8 @@ ruma_api! {
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
/// Creates a new `Request` with the given version.
|
||||
pub fn new(version: &'a str, rooms: Rooms) -> Self {
|
||||
/// Creates a new `Request` with the given version and room key backups.
|
||||
pub fn new(version: &'a str, rooms: BTreeMap<RoomId, RoomKeyBackup>) -> Self {
|
||||
Self { version, rooms }
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::RoomId;
|
||||
|
||||
use super::KeyData;
|
||||
use super::KeyBackupData;
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
@ -32,7 +32,7 @@ ruma_api! {
|
||||
response: {
|
||||
/// Information about the requested backup key.
|
||||
#[ruma_api(body)]
|
||||
pub key_data: KeyData,
|
||||
pub key_data: KeyBackupData,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
@ -47,7 +47,7 @@ impl<'a> Request<'a> {
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given key_data.
|
||||
pub fn new(key_data: KeyData) -> Self {
|
||||
pub fn new(key_data: KeyBackupData) -> Self {
|
||||
Self { key_data }
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use std::collections::BTreeMap;
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::RoomId;
|
||||
|
||||
use super::KeyData;
|
||||
use super::KeyBackupData;
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
@ -29,7 +29,7 @@ ruma_api! {
|
||||
|
||||
response: {
|
||||
/// A map of session IDs to key data.
|
||||
pub sessions: BTreeMap<String, KeyData>,
|
||||
pub sessions: BTreeMap<String, KeyBackupData>,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
@ -44,7 +44,7 @@ impl<'a> Request<'a> {
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given sessions.
|
||||
pub fn new(sessions: BTreeMap<String, KeyData>) -> Self {
|
||||
pub fn new(sessions: BTreeMap<String, KeyBackupData>) -> Self {
|
||||
Self { sessions }
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
//! [GET /_matrix/client/r0/room_keys/keys](https://matrix.org/docs/spec/client_server/unstable#get-matrix-client-r0-room-keys-keys)
|
||||
|
||||
use ruma_api::ruma_api;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use super::Rooms;
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_identifiers::RoomId;
|
||||
|
||||
use super::RoomKeyBackup;
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
@ -22,9 +25,7 @@ ruma_api! {
|
||||
|
||||
response: {
|
||||
/// A map from room IDs to session IDs to key data.
|
||||
///
|
||||
/// Note: synapse has the `sessions: {}` wrapper, the Matrix spec does not.
|
||||
pub rooms: Rooms,
|
||||
pub rooms: BTreeMap<RoomId, RoomKeyBackup>,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
@ -38,8 +39,8 @@ impl<'a> Request<'a> {
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given rooms.
|
||||
pub fn new(rooms: Rooms) -> Self {
|
||||
/// Creates a new `Response` with the given room key backups.
|
||||
pub fn new(rooms: BTreeMap<RoomId, RoomKeyBackup>) -> Self {
|
||||
Self { rooms }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user