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.

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.

Checks if a follow request has been made.

Unfollows someone or something.

Functions

Accepts a follow request, publishes to feeds and federates.

Parameters

  • request: A Request struct or its ID
  • opts: 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{}}
Link to this function

accept_from(subject, opts)

View Source

Accepts a follow request, publishes to feeds and federates.

Parameters

  • subject: The requester
  • opts: 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{}}
Link to this function

all_by_object(user, opts \\ [])

View Source

Lists all follows for an object.

Parameters

  • user: The object whose followers to list
  • opts: Additional options

Returns

List of follows.

Examples

iex> Bonfire.Social.Graph.Follows.all_by_object(user)
[%Follow{}, ...]
Link to this function

all_by_subject(user, opts \\ [])

View Source

Lists all follows by a subject.

Parameters

  • user: The user whose follows to list
  • opts: Additional options

Returns

List of follows.

Examples

iex> Bonfire.Social.Graph.Follows.all_by_subject(user)
[%Follow{}, ...]
Link to this function

all_followed_outboxes(user, opts \\ [])

View Source

Lists all followed outboxes for a user.

Parameters

  • user: The user whose followed outboxes to list
  • opts: 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", ...]
Link to this function

all_objects_by_subject(user, opts \\ [])

View Source

Lists all objects followed by a subject.

Parameters

  • user: The user whose followed objects to list
  • opts: Additional options

Returns

List of followed objects.

Examples

iex> Bonfire.Social.Graph.Follows.all_objects_by_subject(user)
[%FollowedObject{}, ...]
Link to this function

all_subjects_by_object(user, opts \\ [])

View Source

Lists all subjects following an object.

Parameters

  • user: The object whose followers to list
  • opts: Additional options

Returns

List of follower subjects.

Examples

iex> Bonfire.Social.Graph.Follows.all_subjects_by_object(user)
[%FollowerSubject{}, ...]
Link to this function

ap_publish_activity(subject, arg2, object)

View Source

Publishes an ActivityPub activity for a follow-related action.

Parameters

  • subject: The subject of the activity
  • verb: 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{}}
Link to this function

ap_receive_activity(follower, activity, object)

View Source

Receives and processes an ActivityPub activity related to follows.

Parameters

  • follower: The follower
  • activity: The ActivityPub activity
  • object: 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.

Link to this function

follow(user, object, opts \\ [])

View Source

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 follow
  • object: The object to be followed
  • opts: 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{}}
Link to this function

following?(subject, object)

View Source

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
Link to this function

get(subject, object, opts \\ [])

View Source

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{}}
Link to this function

get!(subject, object, opts \\ [])

View Source

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 ignore
  • opts: Additional options

Returns

Result of the ignore operation.

Examples

iex> Bonfire.Social.Graph.Follows.ignore(request, current_user: user)
{:ok, ignored_request}
Link to this function

list_followed(user, opts \\ [])

View Source

Lists followed objects for a given user.

Parameters

  • user: The user whose followed objects to list
  • opts: Additional options

Returns

List of followed objects.

Examples

iex> Bonfire.Social.Graph.Follows.list_followed(user)
[%Object{}, ...]
Link to this function

list_followers(user, opts \\ [])

View Source

Lists followers for a given user.

Parameters

  • user: The user whose followers to list
  • opts: Additional options

Returns

List of followers.

Examples

iex> Bonfire.Social.Graph.Follows.list_followers(user)
[%User{}, ...]
Link to this function

list_my_followed(current_user, opts \\ [])

View Source

Lists followed objects for the current user.

Parameters

  • current_user: The current user
  • opts: Additional options

Returns

List of followed objects.

Examples

iex> Bonfire.Social.Graph.Follows.list_my_followed(current_user)
[%Object{}, ...]
Link to this function

list_my_followers(current_user, opts \\ [])

View Source

Lists followers for the current user.

Parameters

  • current_user: The current user
  • opts: 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 query
  • opts: 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.

Link to this function

requested?(subject, object)

View Source

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.

Link to this function

unfollow(user, object, opts \\ [])

View Source

Unfollows someone or something.

Parameters

  • user: The user who wants to unfollow
  • object: The object to be unfollowed
  • opts: Additional options

Returns

Result of the unfollow operation.

Examples

iex> Bonfire.Social.Graph.Follows.unfollow(me, user2)
{:ok, deleted_follow}