Split UnsignedData into multiple types
* Rename UnsignedData -> Unsigned * Add RedacedUnsigned and RedactedSyncUnsigned
This commit is contained in:
parent
9d94b59f7d
commit
e7d9fb785d
@ -482,7 +482,7 @@ fn generate_accessor(
|
||||
variants: &[Ident],
|
||||
) -> TokenStream {
|
||||
if is_event_kind(kind, var) {
|
||||
let field_type = field_return_type(name);
|
||||
let field_type = field_return_type(name, var);
|
||||
|
||||
let name = Ident::new(name, Span::call_site());
|
||||
let docs = format!("Returns this events {} field.", name);
|
||||
@ -502,14 +502,20 @@ fn generate_accessor(
|
||||
}
|
||||
}
|
||||
|
||||
fn field_return_type(name: &str) -> TokenStream {
|
||||
fn field_return_type(name: &str, var: &EventKindVariation) -> TokenStream {
|
||||
match name {
|
||||
"origin_server_ts" => quote! { ::std::time::SystemTime },
|
||||
"room_id" => quote! { ::ruma_identifiers::RoomId },
|
||||
"event_id" => quote! { ::ruma_identifiers::EventId },
|
||||
"sender" => quote! { ::ruma_identifiers::UserId },
|
||||
"state_key" => quote! { str },
|
||||
"unsigned" => quote! { ::ruma_events::UnsignedData },
|
||||
"unsigned" if &EventKindVariation::RedactedSync == var => {
|
||||
quote! { ::ruma_events::RedactedSyncUnsigned }
|
||||
}
|
||||
"unsigned" if &EventKindVariation::Redacted == var => {
|
||||
quote! { ::ruma_events::RedactedUnsigned }
|
||||
}
|
||||
"unsigned" => quote! { ::ruma_events::Unsigned },
|
||||
_ => panic!("the `ruma_events_macros::event_enum::EVENT_FIELD` const was changed"),
|
||||
}
|
||||
}
|
||||
@ -521,6 +527,7 @@ mod kw {
|
||||
}
|
||||
|
||||
// If the variants of this enum change `to_event_path` needs to be updated as well.
|
||||
#[derive(Eq, PartialEq)]
|
||||
enum EventKindVariation {
|
||||
Full,
|
||||
Sync,
|
||||
|
@ -5,7 +5,8 @@ use ruma_identifiers::{EventId, RoomId, UserId};
|
||||
|
||||
use crate::{
|
||||
BasicEventContent, EphemeralRoomEventContent, EventContent, MessageEventContent,
|
||||
RedactedMessageEventContent, RedactedStateEventContent, StateEventContent, UnsignedData,
|
||||
RedactedMessageEventContent, RedactedStateEventContent, RedactedSyncUnsigned, RedactedUnsigned,
|
||||
StateEventContent, Unsigned,
|
||||
};
|
||||
|
||||
/// A basic event – one that consists only of it's type and the `content` object.
|
||||
@ -51,7 +52,7 @@ pub struct MessageEvent<C: MessageEventContent> {
|
||||
pub room_id: RoomId,
|
||||
|
||||
/// Additional key-value pairs not signed by the homeserver.
|
||||
pub unsigned: UnsignedData,
|
||||
pub unsigned: Unsigned,
|
||||
}
|
||||
|
||||
/// A message event without a `room_id`.
|
||||
@ -70,7 +71,7 @@ pub struct SyncMessageEvent<C: MessageEventContent> {
|
||||
pub origin_server_ts: SystemTime,
|
||||
|
||||
/// Additional key-value pairs not signed by the homeserver.
|
||||
pub unsigned: UnsignedData,
|
||||
pub unsigned: Unsigned,
|
||||
}
|
||||
|
||||
/// A redacted message event.
|
||||
@ -92,7 +93,7 @@ pub struct RedactedMessageEvent<C: RedactedMessageEventContent> {
|
||||
pub room_id: RoomId,
|
||||
|
||||
/// Additional key-value pairs not signed by the homeserver.
|
||||
pub unsigned: UnsignedData,
|
||||
pub unsigned: RedactedUnsigned,
|
||||
}
|
||||
|
||||
/// A redacted message event without a `room_id`.
|
||||
@ -112,7 +113,7 @@ pub struct RedactedSyncMessageEvent<C: RedactedMessageEventContent> {
|
||||
pub origin_server_ts: SystemTime,
|
||||
|
||||
/// Additional key-value pairs not signed by the homeserver.
|
||||
pub unsigned: UnsignedData,
|
||||
pub unsigned: RedactedSyncUnsigned,
|
||||
}
|
||||
|
||||
/// State event.
|
||||
@ -143,7 +144,7 @@ pub struct StateEvent<C: StateEventContent> {
|
||||
pub prev_content: Option<C>,
|
||||
|
||||
/// Additional key-value pairs not signed by the homeserver.
|
||||
pub unsigned: UnsignedData,
|
||||
pub unsigned: Unsigned,
|
||||
}
|
||||
|
||||
/// A state event without a `room_id`.
|
||||
@ -171,7 +172,7 @@ pub struct SyncStateEvent<C: StateEventContent> {
|
||||
pub prev_content: Option<C>,
|
||||
|
||||
/// Additional key-value pairs not signed by the homeserver.
|
||||
pub unsigned: UnsignedData,
|
||||
pub unsigned: Unsigned,
|
||||
}
|
||||
|
||||
/// A stripped-down state event, used for previews of rooms the user has been
|
||||
@ -216,7 +217,7 @@ pub struct RedactedStateEvent<C: RedactedStateEventContent> {
|
||||
pub state_key: String,
|
||||
|
||||
/// Additional key-value pairs not signed by the homeserver.
|
||||
pub unsigned: UnsignedData,
|
||||
pub unsigned: RedactedUnsigned,
|
||||
}
|
||||
|
||||
/// A redacted state event without a `room_id`.
|
||||
@ -242,7 +243,7 @@ pub struct RedactedSyncStateEvent<C: RedactedStateEventContent> {
|
||||
pub state_key: String,
|
||||
|
||||
/// Additional key-value pairs not signed by the homeserver.
|
||||
pub unsigned: UnsignedData,
|
||||
pub unsigned: RedactedSyncUnsigned,
|
||||
}
|
||||
|
||||
/// A stripped-down redacted state event.
|
||||
|
@ -126,7 +126,7 @@ use serde::{
|
||||
};
|
||||
use serde_json::value::RawValue as RawJsonValue;
|
||||
|
||||
use self::room::redaction::RedactionEvent;
|
||||
use self::room::redaction::{RedactionEvent, SyncRedactionEvent};
|
||||
|
||||
#[deprecated = "Use ruma_serde::empty::Empty directly instead."]
|
||||
pub use ruma_serde::empty::Empty;
|
||||
@ -185,7 +185,7 @@ pub use self::{
|
||||
/// Extra information about an event that is not incorporated into the event's
|
||||
/// hash.
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
pub struct UnsignedData {
|
||||
pub struct Unsigned {
|
||||
/// The time in milliseconds that has elapsed since the event was sent. This
|
||||
/// field is generated by the local homeserver, and may be incorrect if the
|
||||
/// local time on at least one of the two servers is out of sync, which can
|
||||
@ -193,17 +193,13 @@ pub struct UnsignedData {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub age: Option<Int>,
|
||||
|
||||
/// The event that redacted this event, if any.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub redacted_because: Option<EventJson<RedactionEvent>>,
|
||||
|
||||
/// The client-supplied transaction ID, if the client being given the event
|
||||
/// is the same one which sent it.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub transaction_id: Option<String>,
|
||||
}
|
||||
|
||||
impl UnsignedData {
|
||||
impl Unsigned {
|
||||
/// Whether this unsigned data is empty (all fields are `None`).
|
||||
///
|
||||
/// This method is used to determine whether to skip serializing the
|
||||
@ -211,7 +207,49 @@ impl UnsignedData {
|
||||
/// an incoming `unsigned` field was present - it could still have been
|
||||
/// present but contained none of the known fields.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.age.is_none() && self.transaction_id.is_none() && self.redacted_because.is_none()
|
||||
self.age.is_none() && self.transaction_id.is_none()
|
||||
}
|
||||
}
|
||||
|
||||
/// Extra information about a redacted event that is not incorporated into the event's
|
||||
/// hash.
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
pub struct RedactedUnsigned {
|
||||
/// The event that redacted this event, if any.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub redacted_because: Option<EventJson<RedactionEvent>>,
|
||||
}
|
||||
|
||||
impl RedactedUnsigned {
|
||||
/// Whether this unsigned data is empty (`redacted_because` is `None`).
|
||||
///
|
||||
/// This method is used to determine whether to skip serializing the
|
||||
/// `unsigned` field in redacted room events. Do not use it to determine whether
|
||||
/// an incoming `unsigned` field was present - it could still have been
|
||||
/// present but contained none of the known fields.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.redacted_because.is_none()
|
||||
}
|
||||
}
|
||||
|
||||
/// Extra information about a redacted sync event that is not incorporated into the sync event's
|
||||
/// hash.
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
pub struct RedactedSyncUnsigned {
|
||||
/// The event that redacted this event, if any.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub redacted_because: Option<EventJson<SyncRedactionEvent>>,
|
||||
}
|
||||
|
||||
impl RedactedSyncUnsigned {
|
||||
/// Whether this unsigned data is empty (`redacted_because` is `None`).
|
||||
///
|
||||
/// This method is used to determine whether to skip serializing the
|
||||
/// `unsignedSync` field in redacted room events. Do not use it to determine whether
|
||||
/// an incoming `unsignedSync` field was present - it could still have been
|
||||
/// present but contained none of the known fields.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.redacted_because.is_none()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ mod tests {
|
||||
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
||||
|
||||
use super::CanonicalAliasEventContent;
|
||||
use crate::{EventJson, StateEvent, UnsignedData};
|
||||
use crate::{EventJson, StateEvent, Unsigned};
|
||||
|
||||
#[test]
|
||||
fn serialization_with_optional_fields_as_none() {
|
||||
@ -55,7 +55,7 @@ mod tests {
|
||||
room_id: RoomId::try_from("!dummy:example.com").unwrap(),
|
||||
sender: UserId::try_from("@carl:example.com").unwrap(),
|
||||
state_key: "".into(),
|
||||
unsigned: UnsignedData::default(),
|
||||
unsigned: Unsigned::default(),
|
||||
};
|
||||
|
||||
let actual = to_json_value(&canonical_alias_event).unwrap();
|
||||
|
@ -405,7 +405,7 @@ mod tests {
|
||||
use super::{AudioMessageEventContent, FormattedBody, MessageEventContent, MessageFormat};
|
||||
use crate::{
|
||||
room::message::{InReplyTo, RelatesTo, TextMessageEventContent},
|
||||
EventJson, MessageEvent, UnsignedData,
|
||||
EventJson, MessageEvent, Unsigned,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@ -421,7 +421,7 @@ mod tests {
|
||||
origin_server_ts: UNIX_EPOCH + Duration::from_millis(10_000),
|
||||
room_id: RoomId::try_from("!testroomid:example.org").unwrap(),
|
||||
sender: UserId::try_from("@user:example.org").unwrap(),
|
||||
unsigned: UnsignedData::default(),
|
||||
unsigned: Unsigned::default(),
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
|
@ -67,7 +67,7 @@ mod tests {
|
||||
use ruma_identifiers::{EventId, RoomId, UserId};
|
||||
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
||||
|
||||
use crate::{EventJson, StateEvent, UnsignedData};
|
||||
use crate::{EventJson, StateEvent, Unsigned};
|
||||
|
||||
use super::NameEventContent;
|
||||
|
||||
@ -81,7 +81,7 @@ mod tests {
|
||||
room_id: RoomId::try_from("!n8f893n9:example.com").unwrap(),
|
||||
sender: UserId::try_from("@carl:example.com").unwrap(),
|
||||
state_key: "".into(),
|
||||
unsigned: UnsignedData::default(),
|
||||
unsigned: Unsigned::default(),
|
||||
};
|
||||
|
||||
let actual = to_json_value(&name_event).unwrap();
|
||||
@ -110,7 +110,7 @@ mod tests {
|
||||
room_id: RoomId::try_from("!n8f893n9:example.com").unwrap(),
|
||||
sender: UserId::try_from("@carl:example.com").unwrap(),
|
||||
state_key: "".into(),
|
||||
unsigned: UnsignedData { age: Some(Int::from(100)), ..UnsignedData::default() },
|
||||
unsigned: Unsigned { age: Some(Int::from(100)), ..Unsigned::default() },
|
||||
};
|
||||
|
||||
let actual = to_json_value(&name_event).unwrap();
|
||||
|
@ -28,7 +28,7 @@ mod tests {
|
||||
use serde_json::to_string;
|
||||
|
||||
use super::PinnedEventsEventContent;
|
||||
use crate::{EventJson, StateEvent, UnsignedData};
|
||||
use crate::{EventJson, StateEvent, Unsigned};
|
||||
|
||||
#[test]
|
||||
fn serialization_deserialization() {
|
||||
@ -46,7 +46,7 @@ mod tests {
|
||||
room_id: RoomId::new(server_name),
|
||||
sender: UserId::new(server_name),
|
||||
state_key: "".into(),
|
||||
unsigned: UnsignedData::default(),
|
||||
unsigned: Unsigned::default(),
|
||||
};
|
||||
|
||||
let serialized_event = to_string(&event).unwrap();
|
||||
|
@ -129,7 +129,7 @@ mod tests {
|
||||
use serde_json::{json, to_value as to_json_value};
|
||||
|
||||
use super::{default_power_level, NotificationPowerLevels, PowerLevelsEventContent};
|
||||
use crate::{EventType, StateEvent, UnsignedData};
|
||||
use crate::{EventType, StateEvent, Unsigned};
|
||||
|
||||
#[test]
|
||||
fn serialization_with_optional_fields_as_none() {
|
||||
@ -152,7 +152,7 @@ mod tests {
|
||||
origin_server_ts: UNIX_EPOCH + Duration::from_millis(1),
|
||||
prev_content: None,
|
||||
room_id: RoomId::try_from("!n8f893n9:example.com").unwrap(),
|
||||
unsigned: UnsignedData::default(),
|
||||
unsigned: Unsigned::default(),
|
||||
sender: UserId::try_from("@carl:example.com").unwrap(),
|
||||
state_key: "".into(),
|
||||
};
|
||||
@ -211,7 +211,7 @@ mod tests {
|
||||
notifications: NotificationPowerLevels { room: Int::from(42) },
|
||||
}),
|
||||
room_id: RoomId::try_from("!n8f893n9:example.com").unwrap(),
|
||||
unsigned: UnsignedData { age: Some(Int::from(100)), ..UnsignedData::default() },
|
||||
unsigned: Unsigned { age: Some(Int::from(100)), ..Unsigned::default() },
|
||||
sender: user,
|
||||
state_key: "".into(),
|
||||
};
|
||||
|
@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
MessageEventContent, RedactedMessageEventContent, RedactedStateEventContent, RoomEventContent,
|
||||
UnsignedData,
|
||||
Unsigned,
|
||||
};
|
||||
|
||||
/// Redaction event.
|
||||
@ -33,7 +33,7 @@ pub struct RedactionEvent {
|
||||
pub room_id: RoomId,
|
||||
|
||||
/// Additional key-value pairs not signed by the homeserver.
|
||||
pub unsigned: UnsignedData,
|
||||
pub unsigned: Unsigned,
|
||||
}
|
||||
|
||||
/// Redaction event without a `room_id`.
|
||||
@ -55,7 +55,7 @@ pub struct SyncRedactionEvent {
|
||||
pub origin_server_ts: SystemTime,
|
||||
|
||||
/// Additional key-value pairs not signed by the homeserver.
|
||||
pub unsigned: UnsignedData,
|
||||
pub unsigned: Unsigned,
|
||||
}
|
||||
|
||||
/// A redaction of an event.
|
||||
|
@ -7,7 +7,7 @@ use matches::assert_matches;
|
||||
use ruma_events::{
|
||||
custom::CustomEventContent, AnyMessageEvent, AnyStateEvent, AnyStateEventContent,
|
||||
AnySyncMessageEvent, AnySyncRoomEvent, EventJson, MessageEvent, StateEvent, SyncMessageEvent,
|
||||
SyncStateEvent, UnsignedData,
|
||||
SyncStateEvent, Unsigned,
|
||||
};
|
||||
use ruma_identifiers::{EventId, RoomId, UserId};
|
||||
use serde_json::{
|
||||
@ -57,7 +57,7 @@ fn serialize_custom_message_event() {
|
||||
origin_server_ts: UNIX_EPOCH + Duration::from_millis(10),
|
||||
room_id: RoomId::try_from("!room:room.com").unwrap(),
|
||||
sender: UserId::try_from("@carl:example.com").unwrap(),
|
||||
unsigned: UnsignedData::default(),
|
||||
unsigned: Unsigned::default(),
|
||||
});
|
||||
|
||||
let actual = to_json_value(&aliases_event).unwrap();
|
||||
@ -99,7 +99,7 @@ fn serialize_custom_state_event() {
|
||||
room_id: RoomId::try_from("!roomid:room.com").unwrap(),
|
||||
sender: UserId::try_from("@carl:example.com").unwrap(),
|
||||
state_key: "".into(),
|
||||
unsigned: UnsignedData::default(),
|
||||
unsigned: Unsigned::default(),
|
||||
});
|
||||
|
||||
let actual = to_json_value(&aliases_event).unwrap();
|
||||
|
@ -12,7 +12,7 @@ use ruma_events::{
|
||||
call::{answer::AnswerEventContent, SessionDescription, SessionDescriptionType},
|
||||
room::{ImageInfo, ThumbnailInfo},
|
||||
sticker::StickerEventContent,
|
||||
AnyMessageEvent, MessageEvent, UnsignedData,
|
||||
AnyMessageEvent, MessageEvent, Unsigned,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@ -92,7 +92,7 @@ fn serialize_message_event() {
|
||||
origin_server_ts: UNIX_EPOCH + Duration::from_millis(1),
|
||||
room_id: RoomId::try_from("!roomid:room.com").unwrap(),
|
||||
sender: UserId::try_from("@carl:example.com").unwrap(),
|
||||
unsigned: UnsignedData::default(),
|
||||
unsigned: Unsigned::default(),
|
||||
});
|
||||
|
||||
let actual = to_json_value(&aliases_event).unwrap();
|
||||
|
@ -9,7 +9,7 @@ use ruma_events::{
|
||||
call::{answer::AnswerEventContent, SessionDescription, SessionDescriptionType},
|
||||
room::{ImageInfo, ThumbnailInfo},
|
||||
sticker::StickerEventContent,
|
||||
AnyMessageEventContent, EventJson, MessageEvent, UnsignedData,
|
||||
AnyMessageEventContent, EventJson, MessageEvent, Unsigned,
|
||||
};
|
||||
use ruma_identifiers::{EventId, RoomId, UserId};
|
||||
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
||||
@ -39,7 +39,7 @@ fn message_serialize_sticker() {
|
||||
origin_server_ts: UNIX_EPOCH + Duration::from_millis(1),
|
||||
room_id: RoomId::try_from("!roomid:room.com").unwrap(),
|
||||
sender: UserId::try_from("@carl:example.com").unwrap(),
|
||||
unsigned: UnsignedData::default(),
|
||||
unsigned: Unsigned::default(),
|
||||
};
|
||||
|
||||
let actual = to_json_value(&aliases_event).unwrap();
|
||||
|
@ -10,28 +10,27 @@ use ruma_events::{
|
||||
aliases::RedactedAliasesEventContent,
|
||||
create::RedactedCreateEventContent,
|
||||
message::RedactedMessageEventContent,
|
||||
redaction::{RedactionEvent, RedactionEventContent},
|
||||
redaction::{RedactionEvent, RedactionEventContent, SyncRedactionEvent},
|
||||
},
|
||||
AnyRedactedMessageEvent, AnyRedactedSyncMessageEvent, AnyRedactedSyncStateEvent, AnyRoomEvent,
|
||||
AnySyncRoomEvent, EventJson, RedactedMessageEvent, RedactedSyncMessageEvent,
|
||||
RedactedSyncStateEvent, UnsignedData,
|
||||
RedactedSyncStateEvent, RedactedSyncUnsigned, RedactedUnsigned, Unsigned,
|
||||
};
|
||||
use ruma_identifiers::{EventId, RoomId, UserId};
|
||||
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
||||
|
||||
fn full_unsigned() -> UnsignedData {
|
||||
let mut unsigned = UnsignedData::default();
|
||||
fn full_unsigned() -> RedactedSyncUnsigned {
|
||||
let mut unsigned = RedactedSyncUnsigned::default();
|
||||
// The presence of `redacted_because` triggers the event enum to return early
|
||||
// with `RedactedContent` instead of failing to deserialize according
|
||||
// to the event type string.
|
||||
unsigned.redacted_because = Some(EventJson::from(RedactionEvent {
|
||||
unsigned.redacted_because = Some(EventJson::from(SyncRedactionEvent {
|
||||
content: RedactionEventContent { reason: Some("redacted because".into()) },
|
||||
redacts: EventId::try_from("$h29iv0s8:example.com").unwrap(),
|
||||
event_id: EventId::try_from("$h29iv0s8:example.com").unwrap(),
|
||||
origin_server_ts: UNIX_EPOCH + Duration::from_millis(1),
|
||||
room_id: RoomId::try_from("!roomid:room.com").unwrap(),
|
||||
sender: UserId::try_from("@carl:example.com").unwrap(),
|
||||
unsigned: UnsignedData::default(),
|
||||
unsigned: Unsigned::default(),
|
||||
}));
|
||||
|
||||
unsigned
|
||||
@ -44,7 +43,7 @@ fn redacted_message_event_serialize() {
|
||||
event_id: EventId::try_from("$h29iv0s8:example.com").unwrap(),
|
||||
origin_server_ts: UNIX_EPOCH + Duration::from_millis(1),
|
||||
sender: UserId::try_from("@carl:example.com").unwrap(),
|
||||
unsigned: UnsignedData::default(),
|
||||
unsigned: RedactedSyncUnsigned::default(),
|
||||
};
|
||||
|
||||
let expected = json!({
|
||||
@ -66,7 +65,7 @@ fn redacted_aliases_event_serialize_no_content() {
|
||||
state_key: "".into(),
|
||||
origin_server_ts: UNIX_EPOCH + Duration::from_millis(1),
|
||||
sender: UserId::try_from("@carl:example.com").unwrap(),
|
||||
unsigned: UnsignedData::default(),
|
||||
unsigned: RedactedSyncUnsigned::default(),
|
||||
};
|
||||
|
||||
let expected = json!({
|
||||
@ -89,7 +88,7 @@ fn redacted_aliases_event_serialize_with_content() {
|
||||
state_key: "".to_string(),
|
||||
origin_server_ts: UNIX_EPOCH + Duration::from_millis(1),
|
||||
sender: UserId::try_from("@carl:example.com").unwrap(),
|
||||
unsigned: UnsignedData::default(),
|
||||
unsigned: RedactedSyncUnsigned::default(),
|
||||
};
|
||||
|
||||
let expected = json!({
|
||||
@ -165,7 +164,7 @@ fn redacted_deserialize_any_room() {
|
||||
|
||||
#[test]
|
||||
fn redacted_deserialize_any_room_sync() {
|
||||
let mut unsigned = UnsignedData::default();
|
||||
let mut unsigned = RedactedUnsigned::default();
|
||||
// The presence of `redacted_because` triggers the event enum (AnySyncRoomEvent in this case)
|
||||
// to return early with `RedactedContent` instead of failing to deserialize according
|
||||
// to the event type string.
|
||||
@ -176,7 +175,7 @@ fn redacted_deserialize_any_room_sync() {
|
||||
origin_server_ts: UNIX_EPOCH + Duration::from_millis(1),
|
||||
room_id: RoomId::try_from("!roomid:room.com").unwrap(),
|
||||
sender: UserId::try_from("@carl:example.com").unwrap(),
|
||||
unsigned: UnsignedData::default(),
|
||||
unsigned: Unsigned::default(),
|
||||
}));
|
||||
|
||||
let redacted = json!({
|
||||
|
@ -6,7 +6,7 @@ use std::{
|
||||
use matches::assert_matches;
|
||||
use ruma_events::{
|
||||
room::redaction::{RedactionEvent, RedactionEventContent},
|
||||
AnyMessageEvent, EventJson, UnsignedData,
|
||||
AnyMessageEvent, EventJson, Unsigned,
|
||||
};
|
||||
use ruma_identifiers::{EventId, RoomId, UserId};
|
||||
use serde_json::{
|
||||
@ -36,7 +36,7 @@ fn serialize_redaction() {
|
||||
origin_server_ts: UNIX_EPOCH + Duration::from_millis(1),
|
||||
room_id: RoomId::try_from("!roomid:room.com").unwrap(),
|
||||
sender: UserId::try_from("@carl:example.com").unwrap(),
|
||||
unsigned: UnsignedData::default(),
|
||||
unsigned: Unsigned::default(),
|
||||
};
|
||||
|
||||
let actual = to_json_value(&aliases_event).unwrap();
|
||||
|
@ -8,7 +8,7 @@ use matches::assert_matches;
|
||||
use ruma_events::{
|
||||
room::{aliases::AliasesEventContent, avatar::AvatarEventContent, ImageInfo, ThumbnailInfo},
|
||||
AnyRoomEvent, AnyStateEvent, AnyStateEventContent, EventJson, StateEvent, SyncStateEvent,
|
||||
UnsignedData,
|
||||
Unsigned,
|
||||
};
|
||||
use ruma_identifiers::{EventId, RoomAliasId, RoomId, UserId};
|
||||
use serde_json::{
|
||||
@ -46,7 +46,7 @@ fn serialize_aliases_with_prev_content() {
|
||||
room_id: RoomId::try_from("!roomid:room.com").unwrap(),
|
||||
sender: UserId::try_from("@carl:example.com").unwrap(),
|
||||
state_key: "".into(),
|
||||
unsigned: UnsignedData::default(),
|
||||
unsigned: Unsigned::default(),
|
||||
};
|
||||
|
||||
let actual = to_json_value(&aliases_event).unwrap();
|
||||
@ -67,7 +67,7 @@ fn serialize_aliases_without_prev_content() {
|
||||
room_id: RoomId::try_from("!roomid:room.com").unwrap(),
|
||||
sender: UserId::try_from("@carl:example.com").unwrap(),
|
||||
state_key: "".into(),
|
||||
unsigned: UnsignedData::default(),
|
||||
unsigned: Unsigned::default(),
|
||||
};
|
||||
|
||||
let actual = to_json_value(&aliases_event).unwrap();
|
||||
|
Loading…
x
Reference in New Issue
Block a user