View Source Bonfire.Social.Graph.Follows (Bonfire v0.9.10-classic-beta.169)
Module for handling follow relationships in the Bonfire social graph.
Summary
Functions
Accepts a follow request, publishes to feeds and federates.
Accepts a follow request, publishes to feeds and federates.
Lists all follows for an object.
Lists all follows by a subject.
Lists all followed outboxes for a user.
Lists all objects followed by a subject.
Lists all subjects following an object.
Publishes an ActivityPub activity for a follow-related action.
Receives and processes an ActivityPub activity related to follows.
Callback implementation for Bonfire.Federate.ActivityPub.FederationModules.federation_module/0
.
Follows someone or something. In case of success, publishes to feeds and federates.
Checks if a subject is following an object.
Gets a follow relationship between a subject and an object, if one exists.
Gets a follow relationship between a subject and an object, raising an error if not found.
Ignores a follow request.
Lists followed objects for a given user.
Lists followers for a given user.
Lists followed objects for the current user.
Lists followers for the current user.
Queries follows based on filters and options.
Callback implementation for Bonfire.Common.ContextModule.query_module/0
.
Checks if a follow request has been made.
Callback implementation for Bonfire.Common.ContextModule.schema_module/0
.
Unfollows someone or something.
Functions
Accepts a follow request, publishes to feeds and federates.
Parameters
request
: ARequest
struct or its IDopts
: Additional options including the current user
Returns
{:ok, follow}
on success, {:error, reason}
on failure.
Examples
iex> Bonfire.Social.Graph.Follows.accept(request, current_user: acceptor)
{:ok, %Follow{}}
Accepts a follow request, publishes to feeds and federates.
Parameters
subject
: The requesteropts
: Additional options including the current user
Returns
{:ok, follow}
on success, {:error, reason}
on failure.
Examples
iex> Bonfire.Social.Graph.Follows.accept_from(requester, current_user: acceptor)
{:ok, %Follow{}}
Lists all follows for an object.
Parameters
user
: The object whose followers to listopts
: Additional options
Returns
List of follows.
Examples
iex> Bonfire.Social.Graph.Follows.all_by_object(user)
[%Follow{}, ...]
Lists all follows by a subject.
Parameters
user
: The user whose follows to listopts
: Additional options
Returns
List of follows.
Examples
iex> Bonfire.Social.Graph.Follows.all_by_subject(user)
[%Follow{}, ...]
Lists all followed outboxes for a user.
Parameters
user
: The user whose followed outboxes to listopts
: Additional options
Returns
List of followed outbox IDs.
Examples
iex> Bonfire.Social.Graph.Follows.all_followed_outboxes(user)
["outbox_id_1", ...]
iex> Bonfire.Social.Graph.Follows.all_followed_outboxes(user, include_followed_categories: true)
["outbox_id_1", "category_outbox_id_1", ...]
Lists all objects followed by a subject.
Parameters
user
: The user whose followed objects to listopts
: Additional options
Returns
List of followed objects.
Examples
iex> Bonfire.Social.Graph.Follows.all_objects_by_subject(user)
[%FollowedObject{}, ...]
Lists all subjects following an object.
Parameters
user
: The object whose followers to listopts
: Additional options
Returns
List of follower subjects.
Examples
iex> Bonfire.Social.Graph.Follows.all_subjects_by_object(user)
[%FollowerSubject{}, ...]
Publishes an ActivityPub activity for a follow-related action.
Parameters
subject
: The subject of the activityverb
: The verb of the activity (e.g., :delete)follow
: The follow object or ID
Returns
{:ok, activity}
on success, {:error, reason}
on failure.
Examples
iex> Bonfire.Social.Graph.Follows.ap_publish_activity(user, :delete, follow)
{:ok, %ActivityPub.Activity{}}
Receives and processes an ActivityPub activity related to follows.
Parameters
follower
: The followeractivity
: The ActivityPub activityobject
: The object of the activity
Returns
{:ok, result}
on success, {:ignore, reason}
on failure or when ignored.
Examples
iex> Bonfire.Social.Graph.Follows.ap_receive_activity(follower, activity, object)
{:ok, %Follow{}}
Callback implementation for Bonfire.Federate.ActivityPub.FederationModules.federation_module/0
.
Follows someone or something. In case of success, publishes to feeds and federates.
If the user is not permitted to follow the object, or the object is a remote actor, it will instead send a request to follow.
Parameters
user
: The user who wants to followobject
: The object to be followedopts
: Additional options
Returns
{:ok, result}
on success, {:error, reason}
on failure.
Examples
iex> Bonfire.Social.Graph.Follows.follow(me, user2)
{:ok, %Follow{}}
iex> Bonfire.Social.Graph.Follows.follow(me, user3)
{:ok, %Request{}}
Checks if a subject is following an object.
Parameters
subject
: The subject (follower)object
: The object (followed)
Returns
Boolean indicating if the subject is following the object.
Examples
iex> Bonfire.Social.Graph.Follows.following?(user, profile)
true
Gets a follow relationship between a subject and an object, if one exists.
Parameters
subject
: The subject (follower)object
: The object (followed)opts
: Additional options
Returns
{:ok, follow}
if found, {:error, :not_found}
otherwise.
Examples
iex> Bonfire.Social.Graph.Follows.get(user, profile)
{:ok, %Follow{}}
Gets a follow relationship between a subject and an object, raising an error if not found.
Ignores a follow request.
Parameters
request
: The request to ignoreopts
: Additional options
Returns
Result of the ignore operation.
Examples
iex> Bonfire.Social.Graph.Follows.ignore(request, current_user: user)
{:ok, ignored_request}
Lists followed objects for a given user.
Parameters
user
: The user whose followed objects to listopts
: Additional options
Returns
List of followed objects.
Examples
iex> Bonfire.Social.Graph.Follows.list_followed(user)
[%Object{}, ...]
Lists followers for a given user.
Parameters
user
: The user whose followers to listopts
: Additional options
Returns
List of followers.
Examples
iex> Bonfire.Social.Graph.Follows.list_followers(user)
[%User{}, ...]
Lists followed objects for the current user.
Parameters
current_user
: The current useropts
: Additional options
Returns
List of followed objects.
Examples
iex> Bonfire.Social.Graph.Follows.list_my_followed(current_user)
[%Object{}, ...]
Lists followers for the current user.
Parameters
current_user
: The current useropts
: Additional options
Returns
List of followers.
Examples
iex> Bonfire.Social.Graph.Follows.list_my_followers(current_user)
[%User{}, ...]
Queries follows based on filters and options.
Parameters
filters
: List of filters to apply to the queryopts
: Additional query options
Returns
An Ecto query for follows.
Examples
iex> Bonfire.Social.Graph.Follows.query([my: :object], current_user: user)
# following
iex> Bonfire.Social.Graph.Follows.query([my: :followers], current_user: user)
# followers
Callback implementation for Bonfire.Common.ContextModule.query_module/0
.
Checks if a follow request has been made.
Parameters
subject
: The subject (requester)object
: The object (requested)
Returns
Boolean indicating if a follow request exists.
Examples
iex> Bonfire.Social.Graph.Follows.requested?(user, profile)
true
Callback implementation for Bonfire.Common.ContextModule.schema_module/0
.
Unfollows someone or something.
Parameters
user
: The user who wants to unfollowobject
: The object to be unfollowedopts
: Additional options
Returns
Result of the unfollow operation.
Examples
iex> Bonfire.Social.Graph.Follows.unfollow(me, user2)
{:ok, deleted_follow}