Skip to content

Add redact method to all event_enum! generated enums#138

Merged
jplatte merged 8 commits intoruma:masterfrom
DevinR528:redact-method-re
Jul 16, 2020
Merged

Add redact method to all event_enum! generated enums#138
jplatte merged 8 commits intoruma:masterfrom
DevinR528:redact-method-re

Conversation

@DevinR528
Copy link
Copy Markdown
Member

@DevinR528 DevinR528 commented Jul 16, 2020

I did some commit manipulation on this I think I'm getting the hang of it!

What do you think of redact returning an Option<RedactedEvent>, the method can validate the EventIds match and whatever else is needed (I think the event ids are it but maybe in the future it could be more complicated)?

@jplatte
Copy link
Copy Markdown
Member

jplatte commented Jul 16, 2020

What do you think of redact returning an Option<RedactedEvent>, the method can validate the EventIds match and whatever else is needed (I think the event ids are it but maybe in the future it could be more complicated)?

I thought about that when proposing these methods, but I feel that it would actually be worse because any code calling this will already have to look for the correct event to apply the redaction to so would end up .unwrap()ing that Option anyway.

maybe in the future it could be more complicated

I don't see how.

pub fn redact_v1(self) -> RedactedAliasesEventContent {
RedactedAliasesEventContent { aliases: Some(self.aliases) }
pub fn redact(self, version: RoomVersionId) -> RedactedAliasesEventContent {
if version.is_version_6() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how we should be handling custom room versions. I thought I had read somewhere that they should generally be considered following the latest room version rules, so this would have to include || version.is_custom(). But I can't find that. Will ask #matrix-spec. But we should still invert this logic so when a new version is introduced, this doesn't revert back to v1 behaviour for that version. Since it's then going to be easier to have custom == v6 logic, let's do that.

@DevinR528
Copy link
Copy Markdown
Member Author

Yes much better! Thanks

@jplatte jplatte merged commit 1db0082 into ruma:master Jul 16, 2020
@DevinR528 DevinR528 deleted the redact-method-re branch May 3, 2021 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants