View Source Bonfire.Social.Boosts (Bonfire v0.9.10-classic-beta.169)

Mutate, query, and federate boosts (re-sharing an activity or object).

Boosts are implemented on top of the Bonfire.Data.Edges.Edge schema (see Bonfire.Social.Edges for shared functions)

Summary

Functions

Publishes a federated activity for a boost action.

Receives and processes a federated boost activity.

Boosts an object for a user.

Checks if a user has boosted an object.

Counts boosts based on filters and options.

Gets the date of the latest boost by a user for an object.

Retrieves a boost edge by subject and object.

Retrieves a boost edge, raising an error if not found.

Lists boosts by a specific user.

Lists boosts by the current user.

Lists boosts of a specific object.

Lists boosts with pagination.

Removes a boost from an object for a user, if one exists

Functions

Link to this function

ap_publish_activity(subject, arg2, boost)

View Source

Publishes a federated activity for a boost action.

Examples

iex> Bonfire.Social.Boosts.ap_publish_activity(subject, :create, boost)
{:ok, _activity}
Link to this function

ap_receive_activity(creator, activity, object)

View Source

Receives and processes a federated boost activity.

Examples

iex> Bonfire.Social.Boosts.ap_receive_activity(creator, activity, object)
{:ok, _boost}
Link to this function

boost(booster, boosted, opts \\ [])

View Source

Boosts an object for a user.

Examples

iex> Bonfire.Social.Boosts.boost(user, object)
{:ok, %Bonfire.Data.Social.Boost{}}

Checks if a user has boosted an object.

Examples

iex> Bonfire.Social.Boosts.boosted?(user, object)
true
Link to this function

count(filters \\ [], opts \\ [])

View Source

Counts boosts based on filters and options.

Examples

iex> Bonfire.Social.Boosts.count([subject: user_id], [])
5 # user made 5 boosts, across all objects

iex> Bonfire.Social.Boosts.count(user, object)
3 # user boosted object 3 times

iex> Bonfire.Social.Boosts.count(object, [])
10 # object was boosted 5 times, across all users
Link to this function

date_last_boosted(user, object)

View Source

Gets the date of the latest boost by a user for an object.

Examples

iex> Bonfire.Social.Boosts.date_last_boosted(user, object)
~U[2023-07-29 12:34:56Z]

Callback implementation for Bonfire.Federate.ActivityPub.FederationModules.federation_module/0.

Link to this function

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

View Source

Retrieves a boost edge by subject and object.

Examples

iex> Bonfire.Social.Boosts.get(subject, object)
{:ok, %Bonfire.Data.Social.Boost{}}
Link to this function

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

View Source

Retrieves a boost edge, raising an error if not found.

Link to this function

list_by(by_user, opts \\ [])

View Source

Lists boosts by a specific user.

Examples

iex> Bonfire.Social.Boosts.list_by(user_id)
[%Bonfire.Data.Social.Boost{}, ...]

Lists boosts by the current user.

Examples

iex> Bonfire.Social.Boosts.list_my(current_user: me)
[%Bonfire.Data.Social.Boost{}, ...]

Lists boosts of a specific object.

Examples

iex> Bonfire.Social.Boosts.list_of(object_id)
[%Bonfire.Data.Social.Boost{}, ...]
Link to this function

list_paginated(filters, opts \\ [])

View Source

Lists boosts with pagination.

Examples

iex> Bonfire.Social.Boosts.list_paginated([subject: user_id], [limit: 10])
%{edges: [%Bonfire.Data.Social.Boost{}, ...], page_info: %{...}}
Link to this function

maybe_boost(booster, boosted, opts \\ [])

View Source

Callback implementation for Bonfire.Common.ContextModule.query_module/0.

Callback implementation for Bonfire.Common.ContextModule.schema_module/0.

Link to this function

unboost(booster, boosted, opts \\ [])

View Source

Removes a boost from an object for a user, if one exists

Examples

iex> Bonfire.Social.Boosts.unboost(user, object)
{:ok, _}