From dfce7349748f734bec78ea2b774d10ac63b4c568 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 17 Jun 2021 18:42:35 +0200 Subject: [PATCH] events: Clean up verification relations --- crates/ruma-events/src/key/verification.rs | 35 ++-------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/crates/ruma-events/src/key/verification.rs b/crates/ruma-events/src/key/verification.rs index 208ca142..5abaf1bc 100644 --- a/crates/ruma-events/src/key/verification.rs +++ b/crates/ruma-events/src/key/verification.rs @@ -4,19 +4,12 @@ //! //! The MSC for the in-room variants of the `m.key.verification.*` events can be found //! [here](https://github.com/matrix-org/matrix-doc/pull/2241). - -#[cfg(feature = "unstable-pre-spec")] -use std::convert::TryFrom; - #[cfg(feature = "unstable-pre-spec")] use ruma_identifiers::EventId; use ruma_serde::StringEnum; #[cfg(feature = "unstable-pre-spec")] use serde::{Deserialize, Serialize}; -#[cfg(feature = "unstable-pre-spec")] -use crate::room::relationships::{Reference, RelatesToJsonRepr, RelationJsonRepr}; - pub mod accept; pub mod cancel; #[cfg(feature = "unstable-pre-spec")] @@ -83,14 +76,14 @@ pub enum ShortAuthenticationString { _Custom(String), } -/// The relation that contains info which event the reaction is applying to. +/// A relation which associates an `m.key.verification.request` with another key verification event. #[derive(Clone, Debug, Deserialize, Serialize)] #[cfg(feature = "unstable-pre-spec")] #[cfg_attr(docsrs, doc(cfg(feature = "unstable-pre-spec")))] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] -#[serde(try_from = "RelatesToJsonRepr", into = "RelatesToJsonRepr")] +#[serde(tag = "rel_type", rename = "m.reference")] pub struct Relation { - /// The event that is being referenced. + /// The event ID of a related `m.key.verification.request`. pub event_id: EventId, } @@ -102,28 +95,6 @@ impl Relation { } } -#[cfg(feature = "unstable-pre-spec")] -impl From for RelatesToJsonRepr { - fn from(relation: Relation) -> Self { - RelatesToJsonRepr::Relation(RelationJsonRepr::Reference(Reference { - event_id: relation.event_id, - })) - } -} - -#[cfg(feature = "unstable-pre-spec")] -impl TryFrom for Relation { - type Error = &'static str; - - fn try_from(value: RelatesToJsonRepr) -> Result { - if let RelatesToJsonRepr::Relation(RelationJsonRepr::Reference(r)) = value { - Ok(Relation { event_id: r.event_id }) - } else { - Err("Expected a relation with a rel_type of `reference`") - } - } -} - /// A Short Authentication String (SAS) verification method. #[derive(Clone, Debug, PartialEq, Eq, StringEnum)] pub enum VerificationMethod {