View Source Mobilizon.Users (Mobilizon v5.0.0-beta.1)

The Users context.

Summary

Functions

Lists the activity settings for an user

Counts users.

Creates an activity setting. Overrides existing values if present

Creates a push subscription.

Creates a setting.

Deletes a push subscription.

Gets the associated actor for an user, either the default set one or the first found.

Gets actors for an user.

Get a push subscription by their endpoint

Gets a single user. Raises Ecto.NoResultsError if the user does not exist.

Get an user by its activation token.

Gets an user by its email.

Get an user by its reset password token.

Get user with its actors.

Get an user with its actors Raises Ecto.NoResultsError if the user does not exist.

Returns the list of administrators.

Returns the list of moderators.

Get a paginated list of all of a user's subscriptions

Returns the list of users.

Registers an user.

Returns a stream of users which want to have a scheduled recap

Updates a setting.

Updates an user.

Updates user's default actor. Raises Ecto.NoResultsError if the user does not exist.

Functions

Link to this function

activity_settings_for_user(user)

View Source

Lists the activity settings for an user

Examples

iex> activity_settings_for_user(user)
[%ActivitySetting{}]

iex> activity_settings_for_user(user)
[]
@spec count_users() :: integer()

Counts users.

Link to this function

create_activity_setting(attrs \\ %{})

View Source

Creates an activity setting. Overrides existing values if present

Examples

iex> create_activity_setting(%{field: value})
{:ok, %ActivitySetting{}}

iex> create_activity_setting(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

create_external(email, provider, args \\ %{})

View Source
@spec create_external(String.t(), String.t(), map()) ::
  {:ok, Mobilizon.Users.User.t()} | {:error, Ecto.Changeset.t()}
Link to this function

create_push_subscription(attrs)

View Source
@spec create_push_subscription(map()) ::
  {:ok, Mobilizon.Users.PushSubscription.t()} | {:error, Ecto.Changeset.t()}

Creates a push subscription.

Examples

iex> create_push_subscription(%{field: value})
{:ok, %PushSubscription{}}

iex> create_push_subscription(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

create_setting(attrs \\ %{})

View Source
@spec create_setting(map()) ::
  {:ok, Mobilizon.Users.Setting.t()} | {:error, Ecto.Changeset.t()}

Creates a setting.

Examples

iex> create_setting(%{field: value})
{:ok, %Setting{}}

iex> create_setting(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

delete_push_subscription(push_subscription)

View Source

Deletes a push subscription.

Examples

iex> delete_push_subscription(push_subscription)
{:ok, %PushSubscription{}}

iex> delete_push_subscription(push_subscription)
{:error, %Ecto.Changeset{}}
Link to this function

delete_user(user, options \\ [reserve_email: true])

View Source

Deletes an user.

Options:

  • reserve_email whether to keep a record of the email so that the user can't register again
Link to this function

get_actor_for_user(user)

View Source
@spec get_actor_for_user(Mobilizon.Users.User.t()) :: Mobilizon.Actors.Actor.t() | nil

Gets the associated actor for an user, either the default set one or the first found.

Link to this function

get_actors_for_user(user)

View Source
@spec get_actors_for_user(Mobilizon.Users.User.t()) :: [Mobilizon.Actors.Actor.t()]

Gets actors for an user.

Link to this function

get_push_subscription_by_endpoint(endpoint)

View Source
@spec get_push_subscription_by_endpoint(String.t()) ::
  Mobilizon.Users.PushSubscription.t() | nil

Get a push subscription by their endpoint

@spec get_setting(Mobilizon.Users.User.t()) :: Mobilizon.Users.Setting.t() | nil
@spec get_setting(String.t() | integer()) :: Mobilizon.Users.Setting.t() | nil
@spec get_user(integer() | String.t() | nil) :: Mobilizon.Users.User.t() | nil
@spec get_user!(integer() | String.t()) :: Mobilizon.Users.User.t()

Gets a single user. Raises Ecto.NoResultsError if the user does not exist.

Link to this function

get_user_by_activation_token(token)

View Source
@spec get_user_by_activation_token(String.t()) :: Mobilizon.Users.User.t() | nil

Get an user by its activation token.

Link to this function

get_user_by_email(email, options \\ [])

View Source
@spec get_user_by_email(String.t(), Keyword.t()) ::
  {:ok, Mobilizon.Users.User.t()} | {:error, :user_not_found}

Gets an user by its email.

Link to this function

get_user_by_reset_password_token(token)

View Source
@spec get_user_by_reset_password_token(String.t()) :: Mobilizon.Users.User.t() | nil

Get an user by its reset password token.

Link to this function

get_user_with_activity_settings!(id)

View Source
Link to this function

get_user_with_actors(id)

View Source
@spec get_user_with_actors(integer()) ::
  {:ok, Mobilizon.Users.User.t()} | {:error, String.t()}

Get user with its actors.

Link to this function

get_user_with_actors!(id)

View Source
@spec get_user_with_actors!(integer() | String.t()) :: Mobilizon.Users.User.t()

Get an user with its actors Raises Ecto.NoResultsError if the user does not exist.

Link to this function

get_user_with_settings!(id)

View Source
Link to this function

get_users_by_email_domain(email_domain)

View Source
@spec get_users_by_email_domain(String.t()) :: [Mobilizon.Users.User.t()]
Link to this function

get_users_by_ip_address(ip_address)

View Source
@spec get_users_by_ip_address(String.t()) :: [Mobilizon.Users.User.t()]
@spec list_admins() :: [Mobilizon.Users.User.t()]

Returns the list of administrators.

@spec list_moderators() :: [Mobilizon.Users.User.t()]

Returns the list of moderators.

Link to this function

list_user_push_subscriptions(user_id, page \\ nil, limit \\ nil)

View Source
@spec list_user_push_subscriptions(
  String.t() | integer(),
  integer() | nil,
  integer() | nil
) ::
  Mobilizon.Storage.Page.t(Mobilizon.Users.PushSubscription.t())

Get a paginated list of all of a user's subscriptions

Returns the list of users.

@spec register(map()) ::
  {:ok, Mobilizon.Users.User.t()} | {:error, Ecto.Changeset.t()}

Registers an user.

Link to this function

stream_users_for_recap()

View Source
@spec stream_users_for_recap() :: Enum.t()

Returns a stream of users which want to have a scheduled recap

Link to this function

update_setting(setting, attrs)

View Source

Updates a setting.

Examples

iex> update_setting(setting, %{field: new_value})
{:ok, %Setting{}}

iex> update_setting(setting, %{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

update_user(user, attrs)

View Source
@spec update_user(Mobilizon.Users.User.t(), map()) ::
  {:ok, Mobilizon.Users.User.t()} | {:error, Ecto.Changeset.t()}

Updates an user.

Link to this function

update_user_default_actor(user, actor)

View Source
@spec update_user_default_actor(
  Mobilizon.Users.User.t(),
  Mobilizon.Actors.Actor.t() | nil
) ::
  Mobilizon.Users.User.t()

Updates user's default actor. Raises Ecto.NoResultsError if the user does not exist.

Link to this function

update_user_email(user, new_email)

View Source
@spec update_user_email(Mobilizon.Users.User.t(), String.t()) ::
  {:ok, Mobilizon.Users.User.t()} | {:error, Ecto.Changeset.t()}
@spec validate_email(Mobilizon.Users.User.t()) ::
  {:ok, Mobilizon.Users.User.t()} | {:error, Ecto.Changeset.t()}