events: Consistently use relates_to for Relation field name
This commit is contained in:
parent
6546add282
commit
090948e04f
@ -55,15 +55,15 @@ pub struct AcceptEventContent {
|
|||||||
|
|
||||||
/// Information about the related event.
|
/// Information about the related event.
|
||||||
#[serde(rename = "m.relates_to")]
|
#[serde(rename = "m.relates_to")]
|
||||||
pub relation: Relation,
|
pub relates_to: Relation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
impl AcceptEventContent {
|
impl AcceptEventContent {
|
||||||
/// Creates a new `AcceptToDeviceEventContent` with the given method-specific content and
|
/// Creates a new `AcceptToDeviceEventContent` with the given method-specific content and
|
||||||
/// relation.
|
/// relation.
|
||||||
pub fn new(method: AcceptMethod, relation: Relation) -> Self {
|
pub fn new(method: AcceptMethod, relates_to: Relation) -> Self {
|
||||||
Self { method, relation }
|
Self { method, relates_to }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ mod tests {
|
|||||||
let event_id = event_id!("$1598361704261elfgc:localhost");
|
let event_id = event_id!("$1598361704261elfgc:localhost");
|
||||||
|
|
||||||
let key_verification_accept_content = AcceptEventContent {
|
let key_verification_accept_content = AcceptEventContent {
|
||||||
relation: Relation { event_id: event_id.clone() },
|
relates_to: Relation { event_id: event_id.clone() },
|
||||||
method: AcceptMethod::SasV1(SasV1Content {
|
method: AcceptMethod::SasV1(SasV1Content {
|
||||||
hash: HashAlgorithm::Sha256,
|
hash: HashAlgorithm::Sha256,
|
||||||
key_agreement_protocol: KeyAgreementProtocol::Curve25519,
|
key_agreement_protocol: KeyAgreementProtocol::Curve25519,
|
||||||
@ -417,7 +417,7 @@ mod tests {
|
|||||||
.deserialize()
|
.deserialize()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
AcceptEventContent {
|
AcceptEventContent {
|
||||||
relation: Relation {
|
relates_to: Relation {
|
||||||
event_id
|
event_id
|
||||||
},
|
},
|
||||||
method: AcceptMethod::SasV1(SasV1Content {
|
method: AcceptMethod::SasV1(SasV1Content {
|
||||||
|
@ -55,14 +55,14 @@ pub struct CancelEventContent {
|
|||||||
|
|
||||||
/// Information about the related event.
|
/// Information about the related event.
|
||||||
#[serde(rename = "m.relates_to")]
|
#[serde(rename = "m.relates_to")]
|
||||||
pub relation: Relation,
|
pub relates_to: Relation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
impl CancelEventContent {
|
impl CancelEventContent {
|
||||||
/// Creates a new `CancelEventContent` with the given reason, code and relation.
|
/// Creates a new `CancelEventContent` with the given reason, code and relation.
|
||||||
pub fn new(reason: String, code: CancelCode, relation: Relation) -> Self {
|
pub fn new(reason: String, code: CancelCode, relates_to: Relation) -> Self {
|
||||||
Self { reason, code, relation }
|
Self { reason, code, relates_to }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,13 +35,13 @@ impl DoneToDeviceEventContent {
|
|||||||
pub struct DoneEventContent {
|
pub struct DoneEventContent {
|
||||||
/// Relation signaling which verification request this event is responding to.
|
/// Relation signaling which verification request this event is responding to.
|
||||||
#[serde(rename = "m.relates_to")]
|
#[serde(rename = "m.relates_to")]
|
||||||
pub relation: Relation,
|
pub relates_to: Relation,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DoneEventContent {
|
impl DoneEventContent {
|
||||||
/// Creates a new `DoneEventContent` with the given relation:
|
/// Creates a new `DoneEventContent` with the given relation.
|
||||||
pub fn new(relation: Relation) -> Self {
|
pub fn new(relates_to: Relation) -> Self {
|
||||||
Self { relation }
|
Self { relates_to }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let content = DoneEventContent { relation: Relation { event_id } };
|
let content = DoneEventContent { relates_to: Relation { event_id } };
|
||||||
|
|
||||||
assert_eq!(to_json_value(&content).unwrap(), json_data);
|
assert_eq!(to_json_value(&content).unwrap(), json_data);
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ mod tests {
|
|||||||
.deserialize()
|
.deserialize()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
DoneEventContent {
|
DoneEventContent {
|
||||||
relation: Relation {
|
relates_to: Relation {
|
||||||
event_id
|
event_id
|
||||||
},
|
},
|
||||||
} if event_id == id
|
} if event_id == id
|
||||||
|
@ -46,13 +46,13 @@ pub struct KeyEventContent {
|
|||||||
|
|
||||||
/// Information about the related event.
|
/// Information about the related event.
|
||||||
#[serde(rename = "m.relates_to")]
|
#[serde(rename = "m.relates_to")]
|
||||||
pub relation: Relation,
|
pub relates_to: Relation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
impl KeyEventContent {
|
impl KeyEventContent {
|
||||||
/// Creates a new `KeyEventContent` with the given key and relation.
|
/// Creates a new `KeyEventContent` with the given key and relation.
|
||||||
pub fn new(key: String, relation: Relation) -> Self {
|
pub fn new(key: String, relates_to: Relation) -> Self {
|
||||||
Self { key, relation }
|
Self { key, relates_to }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,13 +61,13 @@ pub struct MacEventContent {
|
|||||||
|
|
||||||
/// Information about the related event.
|
/// Information about the related event.
|
||||||
#[serde(rename = "m.relates_to")]
|
#[serde(rename = "m.relates_to")]
|
||||||
pub relation: Relation,
|
pub relates_to: Relation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
impl MacEventContent {
|
impl MacEventContent {
|
||||||
/// Creates a new `MacEventContent` with the given key ID to MAC map, key MAC and relation.
|
/// Creates a new `MacEventContent` with the given key ID to MAC map, key MAC and relation.
|
||||||
pub fn new(mac: BTreeMap<String, String>, keys: String, relation: Relation) -> Self {
|
pub fn new(mac: BTreeMap<String, String>, keys: String, relates_to: Relation) -> Self {
|
||||||
Self { mac, keys, relation }
|
Self { mac, keys, relates_to }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ pub struct ReadyEventContent {
|
|||||||
/// Relation signaling which verification request this event is responding
|
/// Relation signaling which verification request this event is responding
|
||||||
/// to.
|
/// to.
|
||||||
#[serde(rename = "m.relates_to")]
|
#[serde(rename = "m.relates_to")]
|
||||||
pub relation: Relation,
|
pub relates_to: Relation,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ReadyEventContent {
|
impl ReadyEventContent {
|
||||||
@ -63,9 +63,9 @@ impl ReadyEventContent {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
from_device: DeviceIdBox,
|
from_device: DeviceIdBox,
|
||||||
methods: Vec<VerificationMethod>,
|
methods: Vec<VerificationMethod>,
|
||||||
relation: Relation,
|
relates_to: Relation,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { from_device, methods, relation }
|
Self { from_device, methods, relates_to }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ mod tests {
|
|||||||
|
|
||||||
let content = ReadyEventContent {
|
let content = ReadyEventContent {
|
||||||
from_device: device.clone(),
|
from_device: device.clone(),
|
||||||
relation: Relation { event_id },
|
relates_to: Relation { event_id },
|
||||||
methods: vec![VerificationMethod::SasV1],
|
methods: vec![VerificationMethod::SasV1],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ mod tests {
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
ReadyEventContent {
|
ReadyEventContent {
|
||||||
from_device,
|
from_device,
|
||||||
relation: Relation {
|
relates_to: Relation {
|
||||||
event_id
|
event_id
|
||||||
},
|
},
|
||||||
methods,
|
methods,
|
||||||
|
@ -65,14 +65,14 @@ pub struct StartEventContent {
|
|||||||
|
|
||||||
/// Information about the related event.
|
/// Information about the related event.
|
||||||
#[serde(rename = "m.relates_to")]
|
#[serde(rename = "m.relates_to")]
|
||||||
pub relation: Relation,
|
pub relates_to: Relation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
impl StartEventContent {
|
impl StartEventContent {
|
||||||
/// Creates a new `StartEventContent` with the given device ID, method and relation.
|
/// Creates a new `StartEventContent` with the given device ID, method and relation.
|
||||||
pub fn new(from_device: DeviceIdBox, method: StartMethod, relation: Relation) -> Self {
|
pub fn new(from_device: DeviceIdBox, method: StartMethod, relates_to: Relation) -> Self {
|
||||||
Self { from_device, method, relation }
|
Self { from_device, method, relates_to }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,7 +420,7 @@ mod tests {
|
|||||||
|
|
||||||
let key_verification_start_content = StartEventContent {
|
let key_verification_start_content = StartEventContent {
|
||||||
from_device: "123".into(),
|
from_device: "123".into(),
|
||||||
relation: Relation { event_id: event_id.clone() },
|
relates_to: Relation { event_id: event_id.clone() },
|
||||||
method: StartMethod::SasV1(
|
method: StartMethod::SasV1(
|
||||||
SasV1Content::new(SasV1ContentInit {
|
SasV1Content::new(SasV1ContentInit {
|
||||||
hashes: vec![HashAlgorithm::Sha256],
|
hashes: vec![HashAlgorithm::Sha256],
|
||||||
@ -451,7 +451,7 @@ mod tests {
|
|||||||
|
|
||||||
let key_verification_start_content = StartEventContent {
|
let key_verification_start_content = StartEventContent {
|
||||||
from_device: "123".into(),
|
from_device: "123".into(),
|
||||||
relation: Relation { event_id: event_id.clone() },
|
relates_to: Relation { event_id: event_id.clone() },
|
||||||
method: StartMethod::ReciprocateV1(ReciprocateV1Content::new(secret.clone())),
|
method: StartMethod::ReciprocateV1(ReciprocateV1Content::new(secret.clone())),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -636,7 +636,7 @@ mod tests {
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
StartEventContent {
|
StartEventContent {
|
||||||
from_device,
|
from_device,
|
||||||
relation: Relation { event_id },
|
relates_to: Relation { event_id },
|
||||||
method: StartMethod::SasV1(SasV1Content {
|
method: StartMethod::SasV1(SasV1Content {
|
||||||
hashes,
|
hashes,
|
||||||
key_agreement_protocols,
|
key_agreement_protocols,
|
||||||
@ -668,7 +668,7 @@ mod tests {
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
StartEventContent {
|
StartEventContent {
|
||||||
from_device,
|
from_device,
|
||||||
relation: Relation { event_id },
|
relates_to: Relation { event_id },
|
||||||
method: StartMethod::ReciprocateV1(ReciprocateV1Content { secret }),
|
method: StartMethod::ReciprocateV1(ReciprocateV1Content { secret }),
|
||||||
} if from_device == "123"
|
} if from_device == "123"
|
||||||
&& event_id == id
|
&& event_id == id
|
||||||
|
@ -42,19 +42,19 @@ pub struct EncryptedEventContent {
|
|||||||
///
|
///
|
||||||
/// [rich replies]: https://matrix.org/docs/spec/client_server/r0.6.1#rich-replies
|
/// [rich replies]: https://matrix.org/docs/spec/client_server/r0.6.1#rich-replies
|
||||||
#[serde(flatten, with = "relation_serde", skip_serializing_if = "Option::is_none")]
|
#[serde(flatten, with = "relation_serde", skip_serializing_if = "Option::is_none")]
|
||||||
pub relation: Option<Relation>,
|
pub relates_to: Option<Relation>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EncryptedEventContent {
|
impl EncryptedEventContent {
|
||||||
/// Creates a new `EncryptedEventContent` with the given scheme and relation.
|
/// Creates a new `EncryptedEventContent` with the given scheme and relation.
|
||||||
pub fn new(scheme: EncryptedEventScheme, relates_to: Option<Relation>) -> Self {
|
pub fn new(scheme: EncryptedEventScheme, relates_to: Option<Relation>) -> Self {
|
||||||
Self { scheme, relation: relates_to }
|
Self { scheme, relates_to }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<EncryptedEventScheme> for EncryptedEventContent {
|
impl From<EncryptedEventScheme> for EncryptedEventContent {
|
||||||
fn from(scheme: EncryptedEventScheme) -> Self {
|
fn from(scheme: EncryptedEventScheme) -> Self {
|
||||||
Self { scheme, relation: None }
|
Self { scheme, relates_to: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ mod tests {
|
|||||||
device_id: "device_id".into(),
|
device_id: "device_id".into(),
|
||||||
session_id: "session_id".into(),
|
session_id: "session_id".into(),
|
||||||
}),
|
}),
|
||||||
relation: Some(Relation::Reply {
|
relates_to: Some(Relation::Reply {
|
||||||
in_reply_to: InReplyTo { event_id: event_id!("$h29iv0s8:example.com") },
|
in_reply_to: InReplyTo { event_id: event_id!("$h29iv0s8:example.com") },
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
@ -223,7 +223,7 @@ mod tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
content.relation,
|
content.relates_to,
|
||||||
Some(Relation::Reply { in_reply_to })
|
Some(Relation::Reply { in_reply_to })
|
||||||
if in_reply_to.event_id == event_id!("$h29iv0s8:example.com")
|
if in_reply_to.event_id == event_id!("$h29iv0s8:example.com")
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user