View Source Bonfire.Social.Pins (Bonfire v0.9.10-classic-beta.169)
Mutate or query pins (which make an activity or object appear at the beginning of feeds or other lists).
This module provides functionality to manage and query pins, including creating, deleting, and listing pins.
Pins are implemented on top of the Bonfire.Data.Edges.Edge
schema (see Bonfire.Social.Edges
for shared functions)
Summary
Functions
Publishes an ActivityPub activity for a pin.
Lists pins of a specific object.
Lists pins by a specific subject.
Callback implementation for Bonfire.Federate.ActivityPub.FederationModules.federation_module/0
.
Retrieves a Pin edge between a subject and an object.
Similar to get/3
, but raises an error if the Pin edge is not found.
Lists pins by a specific user.
Lists pins for the instance.
Lists pins for the current user.
Lists pinners of a specific object or objects.
Creates a pin for an object.
Checks if an object is pinned by the instance.
Callback implementation for Bonfire.Common.ContextModule.query_module/0
.
Sets the rank/position of a pin within a specific scope.
Callback implementation for Bonfire.Common.ContextModule.schema_module/0
.
Removes a pin for an object.
Functions
Publishes an ActivityPub activity for a pin.
Parameters
- subject: The subject of the pin activity.
- verb: The verb of the activity (not used - currently pins are federated out as likes)
- pin: The
Pin
object.
Examples
iex> Bonfire.Social.Pins.ap_publish_activity(%User{id: "user123"}, :create, %Pin{})
{:ok, %ActivityPub.Object{}}
Lists pins of a specific object.
Parameters
- object: The object that was pinned.
- opts: Additional options for the query (optional).
Examples
iex> Bonfire.Social.Pins.by_pinned(%Post{id: "post456"})
[%Pin{}, ...]
Lists pins by a specific subject.
Parameters
- subject: The subject (usually a user) who created the pins.
- opts: Additional options for the query (optional).
Examples
iex> Bonfire.Social.Pins.by_pinner(%User{id: "user123"})
[%Pin{}, ...]
Callback implementation for Bonfire.Federate.ActivityPub.FederationModules.federation_module/0
.
Retrieves a Pin edge between a subject and an object.
Parameters
- subject: The subject (usually a user) of the Pin edge.
- object: The object that was pinned.
- opts: Additional options for the query (optional).
Examples
iex> Bonfire.Social.Pins.get(%User{id: "user123"}, %Post{id: "post456"})
{:ok, %Pin{}}
Similar to get/3
, but raises an error if the Pin edge is not found.
Lists pins by a specific user.
Parameters
- by_user: The user whose pins to list.
- opts: Additional options for the query (optional).
Examples
iex> Bonfire.Social.Pins.list_by(%User{id: "user123"})
%{edges: [%Pin{}, ...], page_info: %{}}
Lists pins for the instance.
Parameters
- opts: Additional options for the query.
Examples
iex> Bonfire.Social.Pins.list_instance_pins(limit: 10)
%{edges: [%Pin{}, ...], page_info: %{}}
Lists pins for the current user.
Parameters
- opts: Additional options for the query.
Examples
iex> Bonfire.Social.Pins.list_my(current_user: %User{id: "user123"})
%{edges: [%Pin{}, ...], page_info: %{}}
Lists pinners of a specific object or objects.
Parameters
- object: The object or objects to find pinners for.
- opts: Additional options for the query (optional).
Examples
iex> Bonfire.Social.Pins.list_of(%Post{id: "post456"})
%{edges: [%Pin{}, ...], page_info: %{}}
Creates a pin for an object.
Parameters
- pinner: The user creating the pin.
- object: The object to be pinned.
- scope: The scope of the pin (eg.
:instance
, optional). - opts: Additional options for creating the pin (optional).
Examples
iex> Bonfire.Social.Pins.pin(%User{id: "user123"}, %Post{id: "post456"})
{:ok, %Pin{}}
iex> Bonfire.Social.Pins.pin(%User{id: "user123"}, %Post{id: "post456"}, :instance)
{:ok, %Pin{}}
Checks if an object is pinned by the instance.
Parameters
- scope: The scope to check for pinning (eg.
:instance
or a user) - object: The object to check for pinning.
Examples
iex> Bonfire.Social.Pins.pinned?(:instance, %Post{id: "post123"})
true
iex> Bonfire.Social.Pins.pinned?(%User{id: "user123"}, %Post{id: "post456"})
false
Callback implementation for Bonfire.Common.ContextModule.query_module/0
.
Sets the rank/position of a pin within a specific scope.
Parameters
- pin: The pin to be ranked.
- scope: The scope for ranking (eg.
:instance
). - position: The desired position/rank for the pin.
Examples
iex> Bonfire.Social.Pins.rank_pin("pin123", :instance, 1)
{:ok, %Bonfire.Data.Assort.Ranked{}}
iex> Bonfire.Social.Pins.rank_pin("pin123", %User{id: "user456"}, 2)
{:ok, %Bonfire.Data.Assort.Ranked{}}
Callback implementation for Bonfire.Common.ContextModule.schema_module/0
.
Removes a pin for an object.
Parameters
- user: The user removing the pin.
- object: The object to be unpinned.
- scope: The scope of the pin (eg.
:instance
, optional).
Examples
iex> Bonfire.Social.Pins.unpin(%User{id: "user123"}, %Post{id: "post456"})
{:ok, nil}
iex> Bonfire.Social.Pins.unpin(%User{id: "user123"}, %Post{id: "post456"}, :instance)
{:ok, nil}