events: Use possibly-redacted content for StrippedStateEvent

This commit is contained in:
Jonas Platte 2023-01-16 19:27:19 +01:00 committed by Jonas Platte
parent 2eba14f0cc
commit 62ed200a56
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
3 changed files with 10 additions and 5 deletions

View File

@ -6,10 +6,10 @@ use serde_json::value::RawValue as RawJsonValue;
use super::{
EphemeralRoomEventContent, EventContent, EventContentFromType, GlobalAccountDataEventContent,
MessageLikeEventContent, MessageLikeEventType, MessageLikeUnsigned, RedactContent,
RedactedMessageLikeEventContent, RedactedStateEventContent, RedactedUnsigned,
RedactionDeHelper, RoomAccountDataEventContent, StateEventType, StaticStateEventContent,
ToDeviceEventContent,
MessageLikeEventContent, MessageLikeEventType, MessageLikeUnsigned,
PossiblyRedactedStateEventContent, RedactContent, RedactedMessageLikeEventContent,
RedactedStateEventContent, RedactedUnsigned, RedactionDeHelper, RoomAccountDataEventContent,
StateEventType, StaticStateEventContent, ToDeviceEventContent,
};
use crate::{
serde::from_raw_json_value, EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId,
@ -285,7 +285,7 @@ pub struct OriginalSyncStateEvent<C: StaticStateEventContent> {
/// A stripped-down state event, used for previews of rooms the user has been invited to.
#[derive(Clone, Debug, Event)]
pub struct StrippedStateEvent<C: StaticStateEventContent> {
pub struct StrippedStateEvent<C: PossiblyRedactedStateEventContent> {
/// Data specific to the event type.
pub content: C,

View File

@ -740,6 +740,8 @@ fn generate_event_type_aliases(
let content_struct = if var.is_redacted() {
Cow::Owned(format_ident!("Redacted{ident}"))
} else if let EventKindVariation::Stripped = var {
Cow::Owned(format_ident!("PossiblyRedacted{ident}"))
} else {
Cow::Borrowed(ident)
};

View File

@ -543,6 +543,9 @@ fn expand_accessor_methods(
}
accessors
} else if var == EventEnumVariation::Stripped {
// There is no content enum for possibly-redacted content types (yet)
TokenStream::new()
} else {
quote! {
/// Returns the content for this event.