events: Deprecate relations event_id methods

This commit is contained in:
Jonas Platte 2023-11-16 14:25:37 +01:00
parent 8d050d7830
commit 1328e52387
No known key found for this signature in database
GPG Key ID: AAA7A61F696C3E0C
5 changed files with 9 additions and 2 deletions

View File

@ -1,5 +1,11 @@
# [unreleased]
Deprecations:
- Deprecate `event_id` methods on `Relation` types
- They will be removed in the next breaking-change release
- Please open an issue if you are currently using them
# 0.27.9
Bug fixes:

View File

@ -126,6 +126,7 @@ impl Relation {
///
/// This is the `event_id` field at the root of an `m.relates_to` object, except in the case of
/// a reply relation where it's the `event_id` field in the `m.in_reply_to` object.
#[deprecated = "Please open an issue if you use this"]
pub fn event_id(&self) -> &EventId {
match self {
Relation::Reply { in_reply_to } => &in_reply_to.event_id,

View File

@ -42,6 +42,7 @@ impl<C> Relation<C> {
///
/// This is the `event_id` field at the root of an `m.relates_to` object, except in the case of
/// a reply relation where it's the `event_id` field in the `m.in_reply_to` object.
#[deprecated = "Please open an issue if you use this"]
pub fn event_id(&self) -> &EventId {
match self {
Relation::Reply { in_reply_to } => &in_reply_to.event_id,
@ -105,6 +106,7 @@ impl RelationWithoutReplacement {
///
/// This is the `event_id` field at the root of an `m.relates_to` object, except in the case of
/// a reply relation where it's the `event_id` field in the `m.in_reply_to` object.
#[deprecated = "Please open an issue if you use this"]
pub fn event_id(&self) -> &EventId {
match self {
Self::Reply { in_reply_to } => &in_reply_to.event_id,

View File

@ -463,7 +463,6 @@ fn custom_relation_deserialization() {
let relation = content.relates_to.unwrap();
assert_eq!(relation.rel_type().unwrap().as_str(), "io.ruma.custom");
assert_eq!(relation.event_id(), "$related_event");
let data = relation.data();
assert_eq!(data.get("field").unwrap().as_str(), Some("value"));
}

View File

@ -269,7 +269,6 @@ fn custom_deserialize() {
})
);
assert_eq!(relation.rel_type().unwrap().as_str(), "io.ruma.unknown");
assert_eq!(relation.event_id().as_str(), "$related_event");
let data = relation.data();
assert_eq!(data.get("key").unwrap().as_str(), Some("value"));
}