Polyjuice Client v0.4.4 Polyjuice.Client.Filter View Source

Build filters.

https://matrix.org/docs/spec/client_server/r0.5.0#filtering

The functions in this module can be chained to create more complex filters.

Examples:

iex> Polyjuice.Client.Filter.include_state_types(["m.room.member"])
...> |> Polyjuice.Client.Filter.limit_timeline_events(10)
...> |> Polyjuice.Client.Filter.lazy_loading()
%{
  "room" => %{
    "state" => %{
      "types" => ["m.room.member"],
      "lazy_load_members" => true
    },
    "timeline" => %{
      "lazy_load_members" => true,
      "limit" => 10
    }
  }
}

Link to this section Summary

Functions

Update the ephemeral filter using a function.

Don't allow certain types of ephemeral room events.

Don't allow certain types of presence events.

Don't allow certain types of state events.

Don't allow certain types of timeline events.

Allow certain types of ephemeral room events to be included.

Allow certain types of presence events to be included.

Allow certain types of state events to be included.

Allow certain types of timeline events to be included.

Set the maximum number of timeline events.

Update the presence filter using a function.

Set the value in a filter.

Update the state filter using a function.

Update the timeline filter using a function.

Update the value in a filter.

Link to this section Functions

Link to this function

ephemeral(filter, f)

View Source
ephemeral(filter :: map(), f :: function()) :: map()

Update the ephemeral filter using a function.

Link to this function

exclude_ephemeral_types(filter \\ %{}, types)

View Source
exclude_ephemeral_types(filter :: map(), types :: list()) :: map()

Don't allow certain types of ephemeral room events.

Link to this function

exclude_presence_types(filter \\ %{}, types)

View Source
exclude_presence_types(filter :: map(), types :: list()) :: map()

Don't allow certain types of presence events.

Link to this function

exclude_state_types(filter \\ %{}, types)

View Source
exclude_state_types(filter :: map(), types :: list()) :: map()

Don't allow certain types of state events.

Link to this function

exclude_timeline_types(filter \\ %{}, types)

View Source
exclude_timeline_types(filter :: map(), types :: list()) :: map()

Don't allow certain types of timeline events.

Link to this function

include_ephemeral_types(filter \\ %{}, types)

View Source
include_ephemeral_types(filter :: map(), types :: list()) :: map()

Allow certain types of ephemeral room events to be included.

Link to this function

include_presence_types(filter \\ %{}, types)

View Source
include_presence_types(filter :: map(), types :: list()) :: map()

Allow certain types of presence events to be included.

Link to this function

include_state_types(filter \\ %{}, types)

View Source
include_state_types(filter :: map(), types :: list()) :: map()

Allow certain types of state events to be included.

Link to this function

include_timeline_types(filter \\ %{}, types)

View Source
include_timeline_types(filter :: map(), types :: list()) :: map()

Allow certain types of timeline events to be included.

Link to this function

lazy_loading(filter \\ %{})

View Source
lazy_loading(filter :: map()) :: map()
Link to this function

limit_timeline_events(filter \\ %{}, limit)

View Source
limit_timeline_events(filter :: map(), limit :: integer()) :: map()

Set the maximum number of timeline events.

Link to this function

presence(filter, f)

View Source
presence(filter :: map(), f :: function()) :: map()

Update the presence filter using a function.

Link to this function

put(filter, key_path, val)

View Source
put(map(), [String.t()], any()) :: map()

Set the value in a filter.

The key_path is a list of keys to traverse to find the element to update. The initial and func arguments are like the corresponding arguments to Map.update.

iex> Polyjuice.Client.Filter.put(
...>   %{
...>     "presence" => %{
...>       "not_senders" => ["@alice:example.com"]
...>     }
...>   },
...>   ["presence", "not_senders"],
...>   ["@bob:example.com"]
...>  )
%{
  "presence" => %{
    "not_senders" => ["@bob:example.com"]
  }
}
Link to this function

state(filter, f)

View Source
state(filter :: map(), f :: function()) :: map()

Update the state filter using a function.

Link to this function

timeline(filter, f)

View Source
timeline(filter :: map(), f :: function()) :: map()

Update the timeline filter using a function.

Link to this function

update(filter, key_path, initial, func)

View Source
update(map(), [String.t()], any(), (any() -> any())) :: map()

Update the value in a filter.

The key_path is a list of keys to traverse to find the element to update. The initial and func arguments are like the corresponding arguments to Map.update.

Examples:

iex> Polyjuice.Client.Filter.update(
...>   %{
...>     "presence" => %{
...>       "not_senders" => ["@alice:example.com"]
...>     }
...>   },
...>   ["presence", "not_senders"],
...>   ["@bob:example.com"],
...>   &Enum.concat(&1, ["@bob:example.com"])
...>  )
%{
  "presence" => %{
    "not_senders" => ["@alice:example.com", "@bob:example.com"]
  }
}

iex> Polyjuice.Client.Filter.update(
...>   %{
...>     "presence" => %{
...>       "not_senders" => ["@alice:example.com"]
...>     }
...>   },
...>   ["presence", "senders"],
...>   ["@bob:example.com"],
...>   &Enum.concat(&1, ["@bob:example.com"])
...>  )
%{
  "presence" => %{
    "not_senders" => ["@alice:example.com"],
    "senders" => ["@bob:example.com"]
  }
}