View Source Mobilizon.Actors (Mobilizon v4.1.0-alpha.1)

The Actors context.

Summary

Functions

Returns whether the actor_id is an administrator for the group parent_id

Build a page struct for followers of an actor.

Build a page struct for followings of an actor.

Checks whether an actor is following another actor.

Returns the number of followers for an actor

Returns the number of followings for an actor

Counts all the groups

Counts the local groups

Creates an actor.

Creates a bot.

Creates a follower.

Creates a group.

Creates a member.

Deletes a bot.

Deletes a follower.

Deletes a follower by followed and following actors.

Deletes a member.

Makes an actor following another actor.

Gets a single actor.

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

Gets an actor by name.

Gets an actor by name and preloads the organized events.

Gets an actor by its URL (ActivityPub ID). The :preload option allows to preload the followers relation.

Gets an actor by its URL (ActivityPub ID). The :preload option allows to preload the followers relation. Raises Ecto.NoResultsError if the actor does not exist.

New function to replace Mobilizon.Actors.get_actor_by_url/1 with better signature

Gets an actor with preloaded relations.

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

Gets the bot associated to an actor.

Gets the default member role depending on the event join options.

Gets a single follower.

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

Gets a follower by the followed actor and following actor

Get a follower by the url.

Gets a group by its actor id.

Gets a group by its title.

Gets a local actor by its preferred username.

Gets a local actor by its preferred username and preloaded relations (organized events, followers and followings).

Gets a local actor with preloaded relations.

Gets a single member.

Gets a single member of an actor (for example a group).

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

Gets a single member of an actor (for example a group).

Returns a relay actor, either relay@domain (Mobilizon) or domain@domain (Mastodon)

Returns the complete list of administrator members for a group.

Returns the list of external followers for an actor.

Returns the paginated list of external followers for an actor.

Returns the list of external followings for an actor.

Lists the groups.

Returns the list of all group ids where the actor_id is the last administrator.

Lists the groups.

Returns the list of groups an actor is member of.

Returns the list of local actors by their username.

Returns the list of members for an actor.

Returns the list of memberships for an user.

Returns whether the actor_id is a confirmed member for the group parent_id

Returns whether the actor_id is a moderator for the group parent_id

Whether the actor needs to be updated.

Creates a new person actor.

Returns whether the member is the last administrator for a group

Registers a new bot.

Builds a page struct for actors by their name or displayed name.

Unfollows an actor (removes a Follower record).

Updates an actor.

Updates a bot.

Updates a follower.

Updates a member.

Upserts an actor. Conflicts on actor's URL/AP ID, replaces keys, avatar and banner, name and summary.

Functions

Link to this function

actor_key_rotation(actor)

View Source
@spec actor_key_rotation(Mobilizon.Actors.Actor.t()) ::
  {:ok, Mobilizon.Actors.Actor.t()} | {:error, Ecto.Changeset.t()}
Link to this function

administrator?(actor_id, parent_id)

View Source
@spec administrator?(integer() | String.t(), integer() | String.t()) :: boolean()

Returns whether the actor_id is an administrator for the group parent_id

Link to this function

build_followers_for_actor(actor, page \\ nil, limit \\ nil)

View Source
@spec build_followers_for_actor(
  Mobilizon.Actors.Actor.t(),
  integer() | nil,
  integer() | nil
) ::
  Mobilizon.Storage.Page.t(Mobilizon.Actors.Follower.t())

Build a page struct for followers of an actor.

Link to this function

build_followings_for_actor(actor, page \\ nil, limit \\ nil)

View Source
@spec build_followings_for_actor(
  Mobilizon.Actors.Actor.t(),
  integer() | nil,
  integer() | nil
) ::
  Mobilizon.Storage.Page.t(Mobilizon.Actors.Follower.t())

Build a page struct for followings of an actor.

Link to this function

check_follow(follower_actor, followed_actor)

View Source

Checks whether an actor is following another actor.

Link to this function

count_followers_for_actor(actor)

View Source
@spec count_followers_for_actor(Mobilizon.Actors.Actor.t()) :: integer()

Returns the number of followers for an actor

Link to this function

count_followings_for_actor(actor)

View Source
@spec count_followings_for_actor(Mobilizon.Actors.Actor.t()) :: integer()

Returns the number of followings for an actor

@spec count_groups() :: integer()

Counts all the groups

@spec count_local_groups() :: integer()

Counts the local groups

Link to this function

count_members_for_group(actor, roles \\ [:member, :moderator, :creator, :administrator])

View Source

Returns the number of members for a group

Link to this function

create_actor(attrs \\ %{})

View Source
@spec create_actor(map()) ::
  {:ok, Mobilizon.Actors.Actor.t()} | {:error, Ecto.Changeset.t()}

Creates an actor.

Link to this function

create_bot(attrs \\ %{})

View Source
@spec create_bot(attrs :: map()) ::
  {:ok, Mobilizon.Actors.Bot.t()} | {:error, Ecto.Changeset.t()}

Creates a bot.

Link to this function

create_follower(attrs \\ %{})

View Source
@spec create_follower(attrs :: map()) ::
  {:ok, Mobilizon.Actors.Follower.t()} | {:error, Ecto.Changeset.t()}

Creates a follower.

Link to this function

create_group(attrs \\ %{})

View Source
@spec create_group(map()) ::
  {:ok, Mobilizon.Actors.Actor.t()} | {:error, Ecto.Changeset.t()}

Creates a group.

If the group is local, creates an admin actor as well from creator_actor_id.

Link to this function

create_member(attrs \\ %{})

View Source
@spec create_member(map()) ::
  {:ok, Mobilizon.Actors.Member.t()} | {:error, Ecto.Changeset.t()}

Creates a member.

Link to this function

delete_actor(actor, options \\ [reserve_username: true, suspension: false])

View Source
@spec delete_actor(Mobilizon.Actors.Actor.t(), Keyword.t()) ::
  {:error, Ecto.Changeset.t()} | {:ok, Oban.Job.t()}
@spec delete_bot(Mobilizon.Actors.Bot.t()) ::
  {:ok, Mobilizon.Actors.Bot.t()} | {:error, Ecto.Changeset.t()}

Deletes a bot.

Link to this function

delete_follower(follower)

View Source
@spec delete_follower(Mobilizon.Actors.Follower.t()) ::
  {:ok, Mobilizon.Actors.Follower.t()} | {:error, Ecto.Changeset.t()}

Deletes a follower.

Link to this function

delete_follower_by_followed_and_following(followed, following)

View Source
@spec delete_follower_by_followed_and_following(
  Mobilizon.Actors.Actor.t(),
  Mobilizon.Actors.Actor.t()
) ::
  {:ok, Mobilizon.Actors.Follower.t()} | {:error, Ecto.Changeset.t()}

Deletes a follower by followed and following actors.

@spec delete_member(Mobilizon.Actors.Member.t()) ::
  {:ok, Mobilizon.Actors.Member.t()} | {:error, Ecto.Changeset.t()}

Deletes a member.

Link to this function

follow(followed, follower, url \\ nil, approved \\ true)

View Source
@spec follow(
  followed :: Mobilizon.Actors.Actor.t(),
  follower :: Mobilizon.Actors.Actor.t(),
  url :: String.t() | nil,
  approved :: boolean() | nil
) ::
  {:ok, Mobilizon.Actors.Follower.t()}
  | {:error,
     :already_following
     | :follow_pending
     | :followed_suspended
     | Ecto.Changeset.t()}

Makes an actor following another actor.

@spec get_actor(integer() | String.t()) :: Mobilizon.Actors.Actor.t() | nil

Gets a single actor.

@spec get_actor!(integer() | String.t()) :: Mobilizon.Actors.Actor.t()

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

Link to this function

get_actor_by_followers_url(followers_url)

View Source
@spec get_actor_by_followers_url(String.t()) :: Mobilizon.Actors.Actor.t() | nil
Link to this function

get_actor_by_name(name, type \\ nil)

View Source
@spec get_actor_by_name(String.t(), atom() | nil) :: Mobilizon.Actors.Actor.t() | nil

Gets an actor by name.

Link to this function

get_actor_by_name_with_preload(name, type \\ nil)

View Source
@spec get_actor_by_name_with_preload(String.t(), atom() | nil) ::
  Mobilizon.Actors.Actor.t() | nil

Gets an actor by name and preloads the organized events.

Link to this function

get_actor_by_url(url, preload \\ false)

View Source
@spec get_actor_by_url(String.t(), boolean()) ::
  {:ok, Mobilizon.Actors.Actor.t()} | {:error, :actor_not_found}

Gets an actor by its URL (ActivityPub ID). The :preload option allows to preload the followers relation.

Link to this function

get_actor_by_url!(url, preload \\ false)

View Source
@spec get_actor_by_url!(String.t(), boolean()) :: Mobilizon.Actors.Actor.t()

Gets an actor by its URL (ActivityPub ID). The :preload option allows to preload the followers relation. Raises Ecto.NoResultsError if the actor does not exist.

@spec get_actor_by_url_2(String.t()) :: Mobilizon.Actors.Actor.t() | nil

New function to replace Mobilizon.Actors.get_actor_by_url/1 with better signature

Link to this function

get_actor_with_preload(id, include_suspended \\ false)

View Source
@spec get_actor_with_preload(integer() | String.t(), boolean()) ::
  Mobilizon.Actors.Actor.t() | nil

Gets an actor with preloaded relations.

Link to this function

get_actor_with_preload!(id)

View Source
@spec get_actor_with_preload!(integer() | String.t()) :: Mobilizon.Actors.Actor.t()

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

Link to this function

get_bot_for_actor(actor)

View Source
@spec get_bot_for_actor(Mobilizon.Actors.Actor.t()) :: Mobilizon.Actors.Bot.t()

Gets the bot associated to an actor.

Link to this function

get_default_member_role(actor)

View Source
@spec get_default_member_role(Mobilizon.Actors.Actor.t()) :: :member | :not_approved

Gets the default member role depending on the event join options.

@spec get_follower(integer() | String.t()) :: Mobilizon.Actors.Follower.t() | nil

Gets a single follower.

@spec get_follower!(integer() | String.t()) :: Mobilizon.Actors.Follower.t()

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

Link to this function

get_follower_by_followed_and_following(actor1, actor2)

View Source
@spec get_follower_by_followed_and_following(
  Mobilizon.Actors.Actor.t(),
  Mobilizon.Actors.Actor.t()
) ::
  Mobilizon.Actors.Follower.t() | nil

Gets a follower by the followed actor and following actor

Link to this function

get_follower_by_url(url)

View Source
@spec get_follower_by_url(String.t()) :: Mobilizon.Actors.Follower.t()

Get a follower by the url.

Link to this function

get_group_by_actor_id(actor_id)

View Source
@spec get_group_by_actor_id(integer() | String.t()) ::
  {:ok, Mobilizon.Actors.Actor.t()} | {:error, :group_not_found}

Gets a group by its actor id.

Link to this function

get_group_by_members_url(members_url)

View Source
@spec get_group_by_members_url(String.t()) :: Mobilizon.Actors.Actor.t() | nil
Link to this function

get_group_by_title(title)

View Source
@spec get_group_by_title(String.t()) :: Mobilizon.Actors.Actor.t() | nil

Gets a group by its title.

Link to this function

get_local_actor_by_name(name)

View Source
@spec get_local_actor_by_name(String.t()) :: Mobilizon.Actors.Actor.t() | nil

Gets a local actor by its preferred username.

Link to this function

get_local_actor_by_name_with_preload(name)

View Source
@spec get_local_actor_by_name_with_preload(String.t()) ::
  Mobilizon.Actors.Actor.t() | nil

Gets a local actor by its preferred username and preloaded relations (organized events, followers and followings).

Link to this function

get_local_actor_with_preload(id)

View Source
@spec get_local_actor_with_preload(integer() | String.t()) ::
  Mobilizon.Actors.Actor.t() | nil

Gets a local actor with preloaded relations.

Link to this function

get_local_group_by_url(group_url)

View Source
@spec get_local_group_by_url(String.t()) :: Mobilizon.Actors.Actor.t() | nil
@spec get_member(integer() | String.t()) :: Mobilizon.Actors.Member.t() | nil

Gets a single member.

Link to this function

get_member(actor_id, parent_id)

View Source
@spec get_member(
  actor_id :: integer() | String.t(),
  parent_id :: integer() | String.t()
) ::
  {:ok, Mobilizon.Actors.Member.t()} | {:error, :member_not_found}

Gets a single member of an actor (for example a group).

Link to this function

get_member(actor_id, parent_id, roles)

View Source
@spec get_member(integer() | String.t(), integer() | String.t(), list()) ::
  {:ok, Mobilizon.Actors.Member.t()} | {:error, :member_not_found}
@spec get_member!(integer() | String.t()) :: Mobilizon.Actors.Member.t()

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

@spec get_member_by_url(String.t()) :: Mobilizon.Actors.Member.t() | nil

Gets a single member of an actor (for example a group).

Link to this function

get_or_create_internal_actor(username)

View Source
@spec get_or_create_internal_actor(String.t()) ::
  {:ok, Mobilizon.Actors.Actor.t()} | {:error, Ecto.Changeset.t()}
@spec get_relay(String.t()) :: Mobilizon.Actors.Actor.t() | nil

Returns a relay actor, either relay@domain (Mobilizon) or domain@domain (Mastodon)

Link to this function

get_single_group_member_actor(group_id)

View Source
@spec get_single_group_member_actor(integer() | String.t()) ::
  Mobilizon.Actors.Actor.t() | nil
Link to this function

get_single_group_moderator_actor(group_id)

View Source
@spec get_single_group_moderator_actor(integer() | String.t()) ::
  Mobilizon.Actors.Actor.t() | nil
@spec last_group_created() :: Mobilizon.Actors.Actor.t() | nil
Link to this function

list_actors(type \\ :Person, preferred_username \\ "", name \\ "", domain \\ "", local \\ true, suspended \\ false, page \\ nil, limit \\ nil)

View Source
@spec list_actors(
  atom(),
  String.t(),
  String.t(),
  String.t(),
  boolean() | nil,
  boolean() | nil,
  integer() | nil,
  integer() | nil
) :: Mobilizon.Storage.Page.t(Mobilizon.Actors.Actor.t())

Returns the list of actors.

Link to this function

list_actors_to_notify_from_group_event(actor)

View Source
@spec list_actors_to_notify_from_group_event(Mobilizon.Actors.Actor.t()) ::
  Mobilizon.Actors.Follower.t()
Link to this function

list_all_administrator_members_for_group(id)

View Source
@spec list_all_administrator_members_for_group(integer() | String.t()) :: [
  Mobilizon.Actors.Member.t()
]

Returns the complete list of administrator members for a group.

Link to this function

list_all_local_members_for_group(group)

View Source
@spec list_all_local_members_for_group(Mobilizon.Actors.Actor.t()) :: [
  Mobilizon.Actors.Member.t()
]
Link to this function

list_external_actors_members_for_group(actor)

View Source
@spec list_external_actors_members_for_group(Mobilizon.Actors.Actor.t()) :: [
  Mobilizon.Actors.Actor.t()
]
Link to this function

list_external_followers_for_actor(actor)

View Source
@spec list_external_followers_for_actor(Mobilizon.Actors.Actor.t()) :: [
  Mobilizon.Actors.Follower.t()
]

Returns the list of external followers for an actor.

Link to this function

list_external_followers_for_actor_paginated(actor, page \\ nil, limit \\ nil)

View Source
@spec list_external_followers_for_actor_paginated(
  Mobilizon.Actors.Actor.t(),
  integer() | nil,
  integer() | nil
) :: Mobilizon.Storage.Page.t(Mobilizon.Actors.Actor.t())

Returns the paginated list of external followers for an actor.

Link to this function

list_external_followings_for_actor_paginated(actor, page \\ nil, limit \\ nil)

View Source
@spec list_external_followings_for_actor_paginated(
  Mobilizon.Actors.Actor.t(),
  integer() | nil,
  integer() | nil
) :: Mobilizon.Storage.Page.t(Mobilizon.Actors.Follower.t())

Returns the list of external followings for an actor.

@spec list_external_groups() :: [Mobilizon.Actors.Actor.t()]

Lists the groups.

Link to this function

list_group_ids_where_last_administrator(actor_id)

View Source
@spec list_group_ids_where_last_administrator(integer() | String.t()) :: [integer()]

Returns the list of all group ids where the actor_id is the last administrator.

Link to this function

list_groups_for_stream()

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

Lists the groups.

Link to this function

list_groups_member_of(actor)

View Source
@spec list_groups_member_of(Mobilizon.Actors.Actor.t()) :: [
  Mobilizon.Actors.Actor.t()
]

Returns the list of groups an actor is member of.

Link to this function

list_internal_actors_members_for_group(actor, roles \\ [])

View Source
@spec list_internal_actors_members_for_group(Mobilizon.Actors.Actor.t(), list()) :: [
  Mobilizon.Actors.Actor.t()
]
Link to this function

list_local_actor_by_username(username)

View Source
@spec list_local_actor_by_username(String.t()) :: [Mobilizon.Actors.Actor.t()]

Returns the list of local actors by their username.

Link to this function

list_members_for_actor(actor, page \\ nil, limit \\ nil)

View Source
@spec list_members_for_actor(
  Mobilizon.Actors.Actor.t(),
  integer() | nil,
  integer() | nil
) ::
  Mobilizon.Storage.Page.t(Mobilizon.Actors.Member.t())

Returns the list of members for an actor.

Link to this function

list_members_for_group(actor, name \\ nil, roles \\ [], page \\ nil, limit \\ nil)

View Source
@spec list_members_for_group(
  Mobilizon.Actors.Actor.t(),
  String.t() | nil,
  [atom()],
  integer() | nil,
  integer() | nil
) :: Mobilizon.Storage.Page.t(Mobilizon.Actors.Member.t())

Returns a paginated list of members for a group.

Link to this function

list_memberships_for_user(user_id, name, page, limit)

View Source
@spec list_memberships_for_user(
  integer(),
  String.t() | nil,
  integer() | nil,
  integer() | nil
) :: Mobilizon.Storage.Page.t(Mobilizon.Actors.Member.t())

Returns the list of memberships for an user.

Default behaviour is to not return :not_approved memberships

Examples

iex> list_event_participations_for_user(5)
%Page{total: 3, elements: [%Participant{}, ...]}
Link to this function

list_paginated_followers_for_actor(actor, approved \\ nil, page \\ nil, limit \\ nil)

View Source
@spec list_paginated_followers_for_actor(
  Mobilizon.Actors.Actor.t(),
  boolean() | nil,
  integer() | nil,
  integer() | nil
) :: Mobilizon.Storage.Page.t(Mobilizon.Actors.Follower.t())

Returns a paginated list of followers for an actor.

Link to this function

list_paginated_follows_for_actor(actor, page \\ nil, limit \\ nil)

View Source
@spec list_paginated_follows_for_actor(
  Mobilizon.Actors.Actor.t(),
  integer() | nil,
  integer() | nil
) ::
  Mobilizon.Storage.Page.t(Mobilizon.Actors.Follower.t())
Link to this function

list_suspended_actors_to_purge(options)

View Source
@spec list_suspended_actors_to_purge(Keyword.t()) :: [Actors.t()]
Link to this function

member?(actor_id, parent_id)

View Source
@spec member?(integer() | String.t(), integer() | String.t()) :: boolean()

Returns whether the actor_id is a confirmed member for the group parent_id

Link to this function

moderator?(actor_id, parent_id)

View Source
@spec moderator?(integer() | String.t(), integer() | String.t()) :: boolean()

Returns whether the actor_id is a moderator for the group parent_id

@spec needs_update?(Mobilizon.Actors.Actor.t()) :: boolean()

Whether the actor needs to be updated.

Local actors obviously don't need to be updated, neither do suspended ones

Link to this function

new_person(args, default_actor \\ false)

View Source
@spec new_person(map(), default_actor :: boolean()) ::
  {:ok, Mobilizon.Actors.Actor.t()} | {:error, Ecto.Changeset.t()}

Creates a new person actor.

Link to this function

only_administrator?(member_id, group_id)

View Source
@spec only_administrator?(integer() | String.t(), integer() | String.t()) :: boolean()

Returns whether the member is the last administrator for a group

@spec register_bot(%{name: String.t(), summary: String.t()}) ::
  {:ok, Mobilizon.Actors.Actor.t()} | {:error, Ecto.Changeset.t()}

Registers a new bot.

Link to this function

schedule_key_rotation(actor, delay)

View Source
@spec schedule_key_rotation(Mobilizon.Actors.Actor.t(), integer()) :: :ok
Link to this function

search_actors(term, options \\ [], page \\ nil, limit \\ nil)

View Source
@spec search_actors(
  String.t(),
  Keyword.t(),
  integer() | nil,
  integer() | nil
) :: Mobilizon.Storage.Page.t(Mobilizon.Actors.Actor.t())

Builds a page struct for actors by their name or displayed name.

Link to this function

should_rotate_actor_key(actor)

View Source
@spec should_rotate_actor_key(Mobilizon.Actors.Actor.t()) :: boolean()
Link to this function

stream_persons(preferred_username \\ "", name \\ "", domain \\ "", local \\ true, suspended \\ false, chunk_size \\ 500)

View Source
@spec stream_persons(
  String.t(),
  String.t(),
  String.t(),
  boolean() | nil,
  boolean() | nil,
  integer()
) :: Enum.t()
Link to this function

unfollow(followed, follower)

View Source

Unfollows an actor (removes a Follower record).

Link to this function

update_actor(actor, attrs)

View Source
@spec update_actor(Mobilizon.Actors.Actor.t(), map()) ::
  {:ok, Mobilizon.Actors.Actor.t()} | {:error, Ecto.Changeset.t()}

Updates an actor.

@spec update_bot(Mobilizon.Actors.Bot.t(), map()) ::
  {:ok, Mobilizon.Actors.Bot.t()} | {:error, Ecto.Changeset.t()}

Updates a bot.

Link to this function

update_follower(follower, attrs)

View Source
@spec update_follower(Mobilizon.Actors.Follower.t(), map()) ::
  {:ok, Mobilizon.Actors.Follower.t()} | {:error, Ecto.Changeset.t()}

Updates a follower.

Link to this function

update_member(member, attrs)

View Source
@spec update_member(Mobilizon.Actors.Member.t(), map()) ::
  {:ok, Mobilizon.Actors.Member.t()} | {:error, Ecto.Changeset.t()}

Updates a member.

Link to this function

upsert_actor(data, preload \\ false)

View Source
@spec upsert_actor(map(), boolean()) ::
  {:ok, Mobilizon.Actors.Actor.t()} | {:error, Ecto.Changeset.t()}

Upserts an actor. Conflicts on actor's URL/AP ID, replaces keys, avatar and banner, name and summary.