Use stable identifiers for m.room_key_bundle and m.history_not_shared
This commit is contained in:
@@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
### Features
|
||||
|
||||
- [**breaking**] Change to the stable identifiers for `m.history_not_shared`.
|
||||
We still support reading the unstable identifier.
|
||||
([#6467](https://github.com/matrix-org/matrix-rust-sdk/pull/6467))
|
||||
- Add a method to check the validity of edits.
|
||||
([#6454](https://github.com/matrix-org/matrix-rust-sdk/pull/6454))
|
||||
- A background task monitor has been added, that can spawn background tasks and monitor their
|
||||
|
||||
@@ -1249,7 +1249,7 @@ pub enum WithheldCode {
|
||||
/// that the session was not marked as "shared_history".
|
||||
///
|
||||
/// [MSC4268]: https://github.com/matrix-org/matrix-spec-proposals/pull/4268
|
||||
#[ruma_enum(rename = "io.element.msc4268.history_not_shared", alias = "m.history_not_shared")]
|
||||
#[ruma_enum(rename = "m.history_not_shared", alias = "io.element.msc4268.history_not_shared")]
|
||||
HistoryNotShared,
|
||||
|
||||
#[doc(hidden)]
|
||||
|
||||
@@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
### Features
|
||||
|
||||
- [**breaking**] Change to the stable identifiers for `m.room_key_bundle` and
|
||||
`m.history_not_shared`. We still support reading the unstable identifiers.
|
||||
([#6467](https://github.com/matrix-org/matrix-rust-sdk/pull/6467))
|
||||
- Add support for MSC4385.
|
||||
([#6164](https://github.com/matrix-org/matrix-rust-sdk/pull/6164))
|
||||
- Add new method `OlmMachine::push_secret_to_verified_devices`.
|
||||
|
||||
@@ -960,8 +960,7 @@ impl OlmMachine {
|
||||
}
|
||||
}
|
||||
|
||||
/// Handle a received, decrypted, `io.element.msc4268.room_key_bundle`
|
||||
/// to-device event.
|
||||
/// Handle a received, decrypted, `m.room_key_bundle` to-device event.
|
||||
#[instrument()]
|
||||
async fn receive_room_key_bundle_data(
|
||||
&self,
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ expression: bundle
|
||||
"withheld": [
|
||||
{
|
||||
"algorithm": "[algorithm]",
|
||||
"code": "io.element.msc4268.history_not_shared",
|
||||
"code": "m.history_not_shared",
|
||||
"from_device": "BOB",
|
||||
"reason": "The sender disabled sharing encrypted history.",
|
||||
"room_id": "!room1:localhost",
|
||||
|
||||
@@ -83,7 +83,7 @@ impl DecryptedForwardedRoomKeyEvent {
|
||||
/// `m.olm.v1.curve25519-aes-sha2` algorithm
|
||||
pub type DecryptedSecretSendEvent = DecryptedOlmV1Event<SecretSendContent>;
|
||||
|
||||
/// An `io.element.msc4268.room_key_bundle` to-device event which has
|
||||
/// An `m.room_key_bundle` to-device event which has
|
||||
/// been decrypted using using the `m.olm.v1.curve25519-aes-sha2` algorithm
|
||||
pub type DecryptedRoomKeyBundleEvent = DecryptedOlmV1Event<RoomKeyBundleContent>;
|
||||
|
||||
@@ -104,7 +104,7 @@ pub enum AnyDecryptedOlmEvent {
|
||||
SecretSend(DecryptedSecretSendEvent),
|
||||
/// The `m.dummy` decrypted to-device event.
|
||||
Dummy(DecryptedDummyEvent),
|
||||
/// The `io.element.msc4268.room_key_bundle` decrypted to-device event.
|
||||
/// The `m.room_key_bundle` decrypted to-device event.
|
||||
RoomKeyBundle(DecryptedRoomKeyBundleEvent),
|
||||
/// The `io.element.msc4385.secret.push` decrypted to-device event.
|
||||
#[cfg(feature = "experimental-push-secrets")]
|
||||
@@ -352,7 +352,7 @@ impl<'de> Deserialize<'de> for AnyDecryptedOlmEvent {
|
||||
}
|
||||
SecretSendContent::EVENT_TYPE => AnyDecryptedOlmEvent::SecretSend(from_str(json)?),
|
||||
DummyEventContent::EVENT_TYPE => AnyDecryptedOlmEvent::Dummy(from_str(json)?),
|
||||
RoomKeyBundleContent::EVENT_TYPE => {
|
||||
RoomKeyBundleContent::EVENT_TYPE | RoomKeyBundleContent::UNSTABLE_EVENT_TYPE => {
|
||||
AnyDecryptedOlmEvent::RoomKeyBundle(from_str(json)?)
|
||||
}
|
||||
#[cfg(feature = "experimental-push-secrets")]
|
||||
@@ -479,7 +479,7 @@ mod tests {
|
||||
})
|
||||
}
|
||||
|
||||
fn room_key_bundle_event_unstable() -> Value {
|
||||
fn room_key_bundle_event(stable: bool) -> Value {
|
||||
json!({
|
||||
"sender": "@u:s.co",
|
||||
"recipient": "@x:s.co",
|
||||
@@ -508,10 +508,18 @@ mod tests {
|
||||
"hashes": {}
|
||||
}
|
||||
},
|
||||
"type": "io.element.msc4268.room_key_bundle"
|
||||
"type": if stable { "m.room_key_bundle" } else { "io.element.msc4268.room_key_bundle" }
|
||||
})
|
||||
}
|
||||
|
||||
fn room_key_bundle_event_stable() -> Value {
|
||||
room_key_bundle_event(true)
|
||||
}
|
||||
|
||||
fn room_key_bundle_event_unstable() -> Value {
|
||||
room_key_bundle_event(false)
|
||||
}
|
||||
|
||||
/// Return the JSON for creating sender device keys, and the matching
|
||||
/// `DeviceKeys` object that should be created when the JSON is
|
||||
/// deserialized.
|
||||
@@ -624,6 +632,9 @@ mod tests {
|
||||
dummy_event => Dummy,
|
||||
|
||||
// `m.room_key_bundle`
|
||||
room_key_bundle_event_stable => RoomKeyBundle,
|
||||
|
||||
// `m.io.element.msc4268.room_key_bundle`
|
||||
room_key_bundle_event_unstable => RoomKeyBundle,
|
||||
);
|
||||
|
||||
@@ -693,7 +704,7 @@ mod tests {
|
||||
|
||||
let event = DecryptedRoomKeyBundleEvent::new(sender, recipient, key, None, content);
|
||||
|
||||
assert_eq!(serde_json::to_value(&event).unwrap(), room_key_bundle_event_unstable());
|
||||
assert_eq!(serde_json::to_value(&event).unwrap(), room_key_bundle_event_stable());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Types for `io.element.msc4268.room_key_bundle` to-device events, per
|
||||
//! [MSC4268].
|
||||
//! Types for `m.room_key_bundle` to-device events, per [MSC4268].
|
||||
//!
|
||||
//! [MSC4268]: https://github.com/matrix-org/matrix-spec-proposals/pull/4268
|
||||
|
||||
@@ -22,7 +21,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::EventType;
|
||||
|
||||
/// The `io.element.msc4268.room_key_bundle` event content. See [MSC4268].
|
||||
/// The `m.room_key_bundle` event content. See [MSC4268].
|
||||
///
|
||||
/// [MSC4268]: https://github.com/matrix-org/matrix-spec-proposals/pull/4268
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
@@ -34,6 +33,11 @@ pub struct RoomKeyBundleContent {
|
||||
pub file: EncryptedFile,
|
||||
}
|
||||
|
||||
impl EventType for RoomKeyBundleContent {
|
||||
const EVENT_TYPE: &'static str = "io.element.msc4268.room_key_bundle";
|
||||
impl RoomKeyBundleContent {
|
||||
/// The unstable event type for MSC4268 m.room_key_bundle
|
||||
pub const UNSTABLE_EVENT_TYPE: &'static str = "io.element.msc4268.room_key_bundle";
|
||||
}
|
||||
|
||||
impl EventType for RoomKeyBundleContent {
|
||||
const EVENT_TYPE: &'static str = "m.room_key_bundle";
|
||||
}
|
||||
|
||||
@@ -1648,9 +1648,9 @@ fn assert_received_room_key_bundle(sync_response: matrix_sdk::sync::SyncResponse
|
||||
"Expected the to-device event to be decrypted"
|
||||
);
|
||||
assert_eq!(
|
||||
"io.element.msc4268.room_key_bundle",
|
||||
"m.room_key_bundle",
|
||||
raw.get_field::<String>("type").unwrap().unwrap(),
|
||||
"Expected the event type to be 'io.element.msc4268.room_key_bundle'"
|
||||
"Expected the event type to be 'm.room_key_bundle'"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,10 +99,7 @@ async fn test_e2ee_state_events() -> Result<()> {
|
||||
assert_eq!(bob_response.to_device.len(), 1);
|
||||
let to_device_event = &bob_response.to_device[0];
|
||||
assert_let!(ProcessedToDeviceEvent::Decrypted { raw, .. } = to_device_event);
|
||||
assert_eq!(
|
||||
raw.get_field::<String>("type").unwrap().unwrap(),
|
||||
"io.element.msc4268.room_key_bundle"
|
||||
);
|
||||
assert_eq!(raw.get_field::<String>("type").unwrap().unwrap(), "m.room_key_bundle");
|
||||
|
||||
bob.get_room(alice_room.room_id()).expect("Bob should have received the invite");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user