ruma_common::canonical_json

Function redact

Source
pub fn redact(
    object: CanonicalJsonObject,
    version: &RoomVersionId,
    redacted_because: Option<RedactedBecause>,
) -> Result<CanonicalJsonObject, RedactionError>
Available on crate feature canonical-json only.
Expand description

Redacts an event using the rules specified in the Matrix client-server specification.

This is part of the process of signing an event.

Redaction is also suggested when verifying an event with verify_event returns Verified::Signatures. See the documentation for Verified for details.

Returns a new JSON object with all applicable fields redacted.

§Parameters

  • object: A JSON object to redact.
  • version: The room version, determines which keys to keep for a few event types.
  • redacted_because: If this is set, an unsigned object with a redacted_because field set to the given value is added to the event after redaction.

§Errors

Returns an error if:

  • object contains a field called content that is not a JSON object.
  • object contains a field called hashes that is not a JSON object.
  • object contains a field called signatures that is not a JSON object.
  • object is missing the type field or the field is not a JSON string.