events: Pass RoomVersionId by reference in redact method

This commit is contained in:
Jonas Platte 2021-05-10 11:24:29 +02:00
parent c648f83cb6
commit 698087337b
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
5 changed files with 5 additions and 5 deletions

View File

@ -187,7 +187,7 @@ pub fn expand_event_content(
#[automatically_derived]
impl #ident {
/// Transforms the full event content into a redacted content according to spec.
pub fn redact(self, version: #ruma_identifiers::RoomVersionId) -> #redacted_ident {
pub fn redact(self, version: &#ruma_identifiers::RoomVersionId) -> #redacted_ident {
#redacted_ident {
#( #redaction_struct_fields: self.#redaction_struct_fields, )*
}

View File

@ -494,7 +494,7 @@ fn expand_redact(
pub fn redact(
self,
redaction: #redaction_type,
version: #ruma_identifiers::RoomVersionId,
version: &#ruma_identifiers::RoomVersionId,
) -> #redacted_enum {
match self {
#(

View File

@ -26,7 +26,7 @@ pub struct CustomEventContent {
impl CustomEventContent {
/// Transforms the full event content into a redacted content according to spec.
pub fn redact(self, _: RoomVersionId) -> RedactedCustomEventContent {
pub fn redact(self, _: &RoomVersionId) -> RedactedCustomEventContent {
RedactedCustomEventContent { event_type: self.event_type }
}
}

View File

@ -28,7 +28,7 @@ impl AliasesEventContent {
}
/// Redact an `AliasesEventContent` according to current Matrix spec.
pub fn redact(self, version: RoomVersionId) -> RedactedAliasesEventContent {
pub fn redact(self, version: &RoomVersionId) -> RedactedAliasesEventContent {
// We compare the long way to avoid pre version 6 behavior if/when
// a new room version is introduced.
let aliases = match version {

View File

@ -346,7 +346,7 @@ fn redact_method_properly_redacts() {
let event = from_json_value::<Raw<AnyMessageEvent>>(ev).unwrap().deserialize().unwrap();
assert_matches!(
event.redact(redaction, RoomVersionId::Version6),
event.redact(redaction, &RoomVersionId::Version6),
AnyRedactedMessageEvent::RoomMessage(RedactedMessageEvent {
content: RedactedMessageEventContent,
event_id,