events: Remove RedactedStrippedStateEvent

Stripped state events are never redacted.
This commit is contained in:
Jonas Platte 2021-09-11 22:12:44 +02:00
parent c33920d8ae
commit bb9f95224c
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
4 changed files with 10 additions and 52 deletions

View File

@ -169,9 +169,9 @@ fn expand_deserialize_event(
EventKindVariation::Redacted | EventKindVariation::RedactedSync => { EventKindVariation::Redacted | EventKindVariation::RedactedSync => {
ty = quote! { #ruma_events::RedactedUnsignedWithPrevContent }; ty = quote! { #ruma_events::RedactedUnsignedWithPrevContent };
} }
EventKindVariation::Stripped EventKindVariation::Stripped | EventKindVariation::Initial => {
| EventKindVariation::Initial unreachable!()
| EventKindVariation::RedactedStripped => unreachable!(), }
} }
} }

View File

@ -341,19 +341,10 @@ fn expand_any_redacted(
expand_any_with_deser(kind, events, attrs, variants, &V::Redacted, ruma_events); expand_any_with_deser(kind, events, attrs, variants, &V::Redacted, ruma_events);
let sync_state = let sync_state =
expand_any_with_deser(kind, events, attrs, variants, &V::RedactedSync, ruma_events); 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! { quote! {
#full_state #full_state
#sync_state #sync_state
#stripped_state
} }
} }
EventKind::Message => { EventKind::Message => {
@ -535,13 +526,6 @@ fn expand_redact(
kind.to_event_enum_ident(&EventKindVariation::RedactedSync)?, 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, _ => return None,
}; };
@ -673,7 +657,7 @@ fn generate_custom_variant(
let serde_json = quote! { #ruma_events::exports::serde_json }; 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! { quote! {
/// A redacted event not defined by the Matrix specification /// A redacted event not defined by the Matrix specification
@ -744,7 +728,7 @@ fn accessor_methods(
let ident = kind.to_event_enum_ident(var)?; let ident = kind.to_event_enum_ident(var)?;
// matching `EventKindVariation`s // 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); 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(var)?,
kind.to_event_enum_ident(&EventKindVariation::RedactedSync)?, kind.to_event_enum_ident(&EventKindVariation::RedactedSync)?,
), ),
EventKindVariation::Stripped => (
kind.to_event_enum_ident(var)?,
kind.to_event_enum_ident(&EventKindVariation::RedactedStripped)?,
),
_ => return None, _ => return None,
}) })
} }

View File

@ -25,7 +25,6 @@ pub enum EventKindVariation {
Initial, Initial,
Redacted, Redacted,
RedactedSync, RedactedSync,
RedactedStripped,
} }
impl fmt::Display for EventKindVariation { impl fmt::Display for EventKindVariation {
@ -37,21 +36,20 @@ impl fmt::Display for EventKindVariation {
EventKindVariation::Initial => write!(f, "Initial"), EventKindVariation::Initial => write!(f, "Initial"),
EventKindVariation::Redacted => write!(f, "Redacted"), EventKindVariation::Redacted => write!(f, "Redacted"),
EventKindVariation::RedactedSync => write!(f, "RedactedSync"), EventKindVariation::RedactedSync => write!(f, "RedactedSync"),
EventKindVariation::RedactedStripped => write!(f, "RedactedStripped"),
} }
} }
} }
impl EventKindVariation { impl EventKindVariation {
pub fn is_redacted(self) -> bool { 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 { pub fn to_full_variation(self) -> Self {
match self { match self {
EventKindVariation::Redacted EventKindVariation::Redacted | EventKindVariation::RedactedSync => {
| EventKindVariation::RedactedSync EventKindVariation::Redacted
| EventKindVariation::RedactedStripped => EventKindVariation::Redacted, }
EventKindVariation::Full EventKindVariation::Full
| EventKindVariation::Sync | EventKindVariation::Sync
| EventKindVariation::Stripped | EventKindVariation::Stripped
@ -125,8 +123,7 @@ impl EventKind {
| (Self::Message, V::Redacted) | (Self::Message, V::Redacted)
| (Self::State, V::Redacted) | (Self::State, V::Redacted)
| (Self::Message, V::RedactedSync) | (Self::Message, V::RedactedSync)
| (Self::State, V::RedactedSync) | (Self::State, V::RedactedSync) => Some(format_ident!("{}{}", var, self)),
| (Self::State, V::RedactedStripped) => Some(format_ident!("{}{}", var, self)),
_ => None, _ => None,
} }
} }
@ -190,9 +187,6 @@ pub fn to_kind_variation(ident: &Ident) -> Option<(EventKind, EventKindVariation
"InitialStateEvent" => Some((EventKind::State, EventKindVariation::Initial)), "InitialStateEvent" => Some((EventKind::State, EventKindVariation::Initial)),
"RedactedStateEvent" => Some((EventKind::State, EventKindVariation::Redacted)), "RedactedStateEvent" => Some((EventKind::State, EventKindVariation::Redacted)),
"RedactedSyncStateEvent" => Some((EventKind::State, EventKindVariation::RedactedSync)), "RedactedSyncStateEvent" => Some((EventKind::State, EventKindVariation::RedactedSync)),
"RedactedStrippedStateEvent" => {
Some((EventKind::State, EventKindVariation::RedactedStripped))
}
"ToDeviceEvent" => Some((EventKind::ToDevice, EventKindVariation::Full)), "ToDeviceEvent" => Some((EventKind::ToDevice, EventKindVariation::Full)),
"PresenceEvent" => Some((EventKind::Presence, EventKindVariation::Full)), "PresenceEvent" => Some((EventKind::Presence, EventKindVariation::Full)),
"RedactionEvent" => Some((EventKind::Redaction, EventKindVariation::Full)), "RedactionEvent" => Some((EventKind::Redaction, EventKindVariation::Full)),

View File

@ -292,22 +292,6 @@ pub struct RedactedSyncStateEvent<C: RedactedStateEventContent> {
pub unsigned: RedactedUnsigned, 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. /// An event sent using send-to-device messaging.
#[derive(Clone, Debug, Event)] #[derive(Clone, Debug, Event)]
pub struct ToDeviceEvent<C: ToDeviceEventContent> { pub struct ToDeviceEvent<C: ToDeviceEventContent> {