View Source Bonfire.Social.APActivities (Bonfire v0.9.10-classic-beta.156)

A special type of activity object that stores federated JSON data as-is.

This module is used for any object type that isn't recognized or isn't implemented by an extension. It provides functionality to handle ActivityPub activities, particularly for receiving and creating activities.

Summary

Functions

Receives and processes an ActivityPub activity.

Creates an APActivity from the given character, activity, and object.

Functions

Link to this function

ap_receive_activity(creator, activity, object)

View Source

Receives and processes an ActivityPub activity.

This function is used to handle incoming federated activities.

Parameters

  • creator: The character (user) associated with the activity.
  • activity: The ActivityPub activity data.
  • object: The object associated with the activity.

Examples

iex> creator = %Character{id: "user123"}
iex> activity = %{data: %{"type" => "Create"}}
iex> object = %{data: %{"type" => "Note", "content" => "Hello, fediverse!"}}
iex> Bonfire.Social.APActivities.ap_receive_activity(creator, activity, object)
{:ok, %APActivity{}}
Link to this function

create(character, activity, object, public \\ nil)

View Source

Creates an APActivity from the given character, activity, and object.

This function handles various patterns of input data to create an APActivity.

Parameters

  • character: The character (user) creating the activity.
  • activity: The activity data.
  • object: The object associated with the activity.
  • public: A boolean indicating whether the activity is public (optional).

Examples

iex> character = %Character{id: "user123"}
iex> activity = %{data: %{"type" => "Create", "object" => %{"content" => "Hello, world!"}}}
iex> object = %{data: %{"type" => "Note"}}
iex> Bonfire.Social.APActivities.create(character, activity, object)
{:ok, %APActivity{}}

iex> Bonfire.Social.APActivities.create(character, activity, object, true)
{:ok, %APActivity{}}