Polyjuice Util v0.1.0 Polyjuice.Util.Event View Source

Event-related functions.

Link to this section Summary

Functions

Calculate the redacted version of an event for the given room version.

Link to this section Functions

Link to this function

redact(room_version, event)

View Source
redact(room_version :: String.t(), event :: map()) :: {:ok, map()} | :error

Calculate the redacted version of an event for the given room version.

Examples:

iex> Polyjuice.Util.Event.redact(
...>   "1",
...>   %{
...>     "content" => %{
...>       "body" => "Here is the message content"
...>     },
...>     "event_id" => "$0:domain",
...>     "origin" => "domain",
...>     "origin_server_ts" => 1000000,
...>     "type" => "m.room.message",
...>     "room_id" => "!r:domain",
...>     "sender" => "@u:domain",
...>     "signatures" => %{},
...>     "unsigned" => %{
...>       "age_ts" => 1000000
...>     }
...>   }
...> )
{
  :ok,
  %{
    "content" => %{},
    "event_id" => "$0:domain",
    "origin" => "domain",
    "origin_server_ts" => 1000000,
    "type" => "m.room.message",
    "room_id" => "!r:domain",
    "sender" => "@u:domain",
    "signatures" => %{}
  }
}

iex> Polyjuice.Util.Event.redact(
...>   "unknown room version",
...>   %{}
...> )
:error