Bonfire.Boundaries.Controlleds (Bonfire v1.0.2-social-alpha.27)
View SourceAn object is linked to one or more Acls by the Controlled multimixin, which pairs an object ID with an ACL ID.
Because it is a multimixin, a given object can have multiple ACLs applied. In the case of overlap, permissions are combined with false being prioritised.
The Controlled multimixin link an object to one or more ACLs. This allows for applying multiple boundaries to the same object. In case of overlapping permissions, the system combines them following the logic described in Bonfire.Boundaries.
The corresponding Ecto schema is Bonfire.Data.AccessControl.Controlled which is defined in a seperate repo.
Summary
Functions
Adds the given ACL to an object.
Returns a changeset for a Controlled with the given attributes.
Creates a Controlled record with the given attributes.
Gets a preset ACL applied to an object, if any.
Grants a role to a subject for an object.
Lists ACLs applied to an object. Only call this as an admin or curator of the object.
Lists grants of a given verb on specified object(s).
Checks which objects have grants to the followers stereotype circle.
Lists ALL boundaries (ACLs and grants) applied to an object. Only call this as an admin or curator of the object.
Lists ACLs applied to the given objects by the subject (current_user).
Returns the set of ACL IDs for a single object, for visibility detection.
Lists all preset ACL IDs applied to each object, for visibility detection.
Lists presets ACLs applied to the given objects.
Lists subjects who have been granted a given verb on specified object(s).
Checks if a single object has a grant to the followers stereotype circle.
Removes the given ACLs from an object.
Functions
Adds the given ACL to an object.
Examples
iex> add_acls(object, :acl)
{:ok, %Controlled{}}
Returns a changeset for a Controlled with the given attributes.
Examples
iex> changeset(%Controlled{}, %{field: value})
%Ecto.Changeset{}
Creates a Controlled record with the given attributes.
Examples
iex> create(%{field: value})
{:ok, %Controlled{}}
Gets a preset ACL applied to an object, if any.
Examples
iex> get_preset_on_object(object)
%ACL{}
Grants a role to a subject for an object.
Examples
iex> grant_role(subject_id, object, :editor)
{:ok, %Grant{}}
Lists ACLs applied to an object. Only call this as an admin or curator of the object.
Examples
iex> list_acls_on_object(object)
[%Acl{}]
Lists grants of a given verb on specified object(s).
Examples
iex> list_grants_by_verbs(objects, :read)
iex> list_grants_by_verbs(objects, :edit, false)
Checks which objects have grants to the followers stereotype circle.
Used to distinguish Mastodon "private" (followers + mentions) from "direct" (mentions only) when an object has no preset ACLs.
Returns a MapSet of object IDs that have at least one grant targeting the followers circle.
Lists ALL boundaries (ACLs and grants) applied to an object. Only call this as an admin or curator of the object.
Examples
iex> list_on_object(object)
[%Boundary{}]
Lists ACLs applied to the given objects by the subject (current_user).
Examples
iex> list_on_objects_by_subject(objects, current_user)
%{object1_id => [%Acl{}], object2_id => [%Acl{}]}
Returns the set of ACL IDs for a single object, for visibility detection.
Lists all preset ACL IDs applied to each object, for visibility detection.
Unlike list_presets_on_objects/1 which returns one "best" ACL per object,
this returns the full set of ACL IDs, enabling set-based visibility matching
(e.g., distinguishing "public" from "unlisted" by checking for remote interaction ACLs).
Returns %{object_id => MapSet.t(acl_id)}.
Lists presets ACLs applied to the given objects.
Examples
iex> list_presets_on_objects(objects)
%{object_id => %Preset{}}
Lists subjects who have been granted a given verb on specified object(s).
Examples
iex> list_subjects_by_verb(objects, :read)
iex> list_subjects_by_verb(objects, :edit, false)
Checks if a single object has a grant to the followers stereotype circle.
Removes the given ACLs from an object.
Examples
iex> remove_acls(object, acls)