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.
Deletes an user.
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
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.
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{}}
@spec create_external(String.t(), String.t(), map()) :: {:ok, Mobilizon.Users.User.t()} | {:error, Ecto.Changeset.t()}
@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{}}
@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{}}
Deletes a push subscription.
Examples
iex> delete_push_subscription(push_subscription)
{:ok, %PushSubscription{}}
iex> delete_push_subscription(push_subscription)
{:error, %Ecto.Changeset{}}
Deletes an user.
Options:
reserve_email
whether to keep a record of the email so that the user can't register again
@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.
@spec get_actors_for_user(Mobilizon.Users.User.t()) :: [Mobilizon.Actors.Actor.t()]
Gets actors for an user.
@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.
@spec get_user_by_activation_token(String.t()) :: Mobilizon.Users.User.t() | nil
Get an user by its activation token.
@spec get_user_by_email(String.t(), Keyword.t()) :: {:ok, Mobilizon.Users.User.t()} | {:error, :user_not_found}
Gets an user by its email.
@spec get_user_by_reset_password_token(String.t()) :: Mobilizon.Users.User.t() | nil
Get an user by its reset password token.
@spec get_user_with_actors(integer()) :: {:ok, Mobilizon.Users.User.t()} | {:error, String.t()}
Get user with its actors.
@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.
@spec get_users_by_email_domain(String.t()) :: [Mobilizon.Users.User.t()]
@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.
@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
@spec list_users(Keyword.t()) :: Mobilizon.Storage.Page.t(Mobilizon.Users.User.t())
Returns the list of users.
@spec register(map()) :: {:ok, Mobilizon.Users.User.t()} | {:error, Ecto.Changeset.t()}
Registers an user.
@spec stream_users_for_recap() :: Enum.t()
Returns a stream of users which want to have a scheduled recap
Updates a setting.
Examples
iex> update_setting(setting, %{field: new_value})
{:ok, %Setting{}}
iex> update_setting(setting, %{field: bad_value})
{:error, %Ecto.Changeset{}}
@spec update_user(Mobilizon.Users.User.t(), map()) :: {:ok, Mobilizon.Users.User.t()} | {:error, Ecto.Changeset.t()}
Updates an user.
@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.
@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()}