events: Remove RedactedStrippedStateEvent
Stripped state events are never redacted.
This commit is contained in:
parent
c33920d8ae
commit
bb9f95224c
@ -169,9 +169,9 @@ fn expand_deserialize_event(
|
||||
EventKindVariation::Redacted | EventKindVariation::RedactedSync => {
|
||||
ty = quote! { #ruma_events::RedactedUnsignedWithPrevContent };
|
||||
}
|
||||
EventKindVariation::Stripped
|
||||
| EventKindVariation::Initial
|
||||
| EventKindVariation::RedactedStripped => unreachable!(),
|
||||
EventKindVariation::Stripped | EventKindVariation::Initial => {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -341,19 +341,10 @@ fn expand_any_redacted(
|
||||
expand_any_with_deser(kind, events, attrs, variants, &V::Redacted, ruma_events);
|
||||
let sync_state =
|
||||
expand_any_with_deser(kind, events, attrs, variants, &V::RedactedSync, ruma_events);
|
||||
let stripped_state = expand_any_with_deser(
|
||||
kind,
|
||||
events,
|
||||
attrs,
|
||||
variants,
|
||||
&V::RedactedStripped,
|
||||
ruma_events,
|
||||
);
|
||||
|
||||
quote! {
|
||||
#full_state
|
||||
#sync_state
|
||||
#stripped_state
|
||||
}
|
||||
}
|
||||
EventKind::Message => {
|
||||
@ -535,13 +526,6 @@ fn expand_redact(
|
||||
kind.to_event_enum_ident(&EventKindVariation::RedactedSync)?,
|
||||
)
|
||||
}
|
||||
EventKindVariation::Stripped => {
|
||||
let struct_id = kind.to_event_ident(&EventKindVariation::RedactedStripped)?;
|
||||
(
|
||||
quote! { #ruma_events::#struct_id },
|
||||
kind.to_event_enum_ident(&EventKindVariation::RedactedStripped)?,
|
||||
)
|
||||
}
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
@ -673,7 +657,7 @@ fn generate_custom_variant(
|
||||
|
||||
let serde_json = quote! { #ruma_events::exports::serde_json };
|
||||
|
||||
if matches!(var, V::Redacted | V::RedactedSync | V::RedactedStripped) {
|
||||
if matches!(var, V::Redacted | V::RedactedSync) {
|
||||
(
|
||||
quote! {
|
||||
/// A redacted event not defined by the Matrix specification
|
||||
@ -744,7 +728,7 @@ fn accessor_methods(
|
||||
let ident = kind.to_event_enum_ident(var)?;
|
||||
|
||||
// matching `EventKindVariation`s
|
||||
if let V::Redacted | V::RedactedSync | V::RedactedStripped = var {
|
||||
if let V::Redacted | V::RedactedSync = var {
|
||||
return redacted_accessor_methods(kind, var, variants, ruma_events);
|
||||
}
|
||||
|
||||
@ -822,10 +806,6 @@ fn inner_enum_idents(kind: &EventKind, var: &EventKindVariation) -> Option<(Iden
|
||||
kind.to_event_enum_ident(var)?,
|
||||
kind.to_event_enum_ident(&EventKindVariation::RedactedSync)?,
|
||||
),
|
||||
EventKindVariation::Stripped => (
|
||||
kind.to_event_enum_ident(var)?,
|
||||
kind.to_event_enum_ident(&EventKindVariation::RedactedStripped)?,
|
||||
),
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ pub enum EventKindVariation {
|
||||
Initial,
|
||||
Redacted,
|
||||
RedactedSync,
|
||||
RedactedStripped,
|
||||
}
|
||||
|
||||
impl fmt::Display for EventKindVariation {
|
||||
@ -37,21 +36,20 @@ impl fmt::Display for EventKindVariation {
|
||||
EventKindVariation::Initial => write!(f, "Initial"),
|
||||
EventKindVariation::Redacted => write!(f, "Redacted"),
|
||||
EventKindVariation::RedactedSync => write!(f, "RedactedSync"),
|
||||
EventKindVariation::RedactedStripped => write!(f, "RedactedStripped"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl EventKindVariation {
|
||||
pub fn is_redacted(self) -> bool {
|
||||
matches!(self, Self::Redacted | Self::RedactedSync | Self::RedactedStripped)
|
||||
matches!(self, Self::Redacted | Self::RedactedSync)
|
||||
}
|
||||
|
||||
pub fn to_full_variation(self) -> Self {
|
||||
match self {
|
||||
EventKindVariation::Redacted | EventKindVariation::RedactedSync => {
|
||||
EventKindVariation::Redacted
|
||||
| EventKindVariation::RedactedSync
|
||||
| EventKindVariation::RedactedStripped => EventKindVariation::Redacted,
|
||||
}
|
||||
EventKindVariation::Full
|
||||
| EventKindVariation::Sync
|
||||
| EventKindVariation::Stripped
|
||||
@ -125,8 +123,7 @@ impl EventKind {
|
||||
| (Self::Message, V::Redacted)
|
||||
| (Self::State, V::Redacted)
|
||||
| (Self::Message, V::RedactedSync)
|
||||
| (Self::State, V::RedactedSync)
|
||||
| (Self::State, V::RedactedStripped) => Some(format_ident!("{}{}", var, self)),
|
||||
| (Self::State, V::RedactedSync) => Some(format_ident!("{}{}", var, self)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@ -190,9 +187,6 @@ pub fn to_kind_variation(ident: &Ident) -> Option<(EventKind, EventKindVariation
|
||||
"InitialStateEvent" => Some((EventKind::State, EventKindVariation::Initial)),
|
||||
"RedactedStateEvent" => Some((EventKind::State, EventKindVariation::Redacted)),
|
||||
"RedactedSyncStateEvent" => Some((EventKind::State, EventKindVariation::RedactedSync)),
|
||||
"RedactedStrippedStateEvent" => {
|
||||
Some((EventKind::State, EventKindVariation::RedactedStripped))
|
||||
}
|
||||
"ToDeviceEvent" => Some((EventKind::ToDevice, EventKindVariation::Full)),
|
||||
"PresenceEvent" => Some((EventKind::Presence, EventKindVariation::Full)),
|
||||
"RedactionEvent" => Some((EventKind::Redaction, EventKindVariation::Full)),
|
||||
|
@ -292,22 +292,6 @@ pub struct RedactedSyncStateEvent<C: RedactedStateEventContent> {
|
||||
pub unsigned: RedactedUnsigned,
|
||||
}
|
||||
|
||||
/// A stripped-down redacted state event.
|
||||
#[derive(Clone, Debug, Event)]
|
||||
pub struct RedactedStrippedStateEvent<C: RedactedStateEventContent> {
|
||||
/// Data specific to the event type.
|
||||
pub content: C,
|
||||
|
||||
/// The fully-qualified ID of the user who sent this event.
|
||||
pub sender: UserId,
|
||||
|
||||
/// A unique key which defines the overwriting semantics for this piece of room state.
|
||||
///
|
||||
/// This is often an empty string, but some events send a `UserId` to show which user the event
|
||||
/// affects.
|
||||
pub state_key: String,
|
||||
}
|
||||
|
||||
/// An event sent using send-to-device messaging.
|
||||
#[derive(Clone, Debug, Event)]
|
||||
pub struct ToDeviceEvent<C: ToDeviceEventContent> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user