View Source Bonfire.Social (Bonfire v0.9.10-classic-beta.169)
An extension for Bonfire that handles:
- Feeds / Timelines
- Activities
- Threads
- Boosting
- Liking
- Flagging
- etc
Handy commands
Copyright and License
Copyright (c) 2023 Bonfire Contributors
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Summary
Functions
Callback implementation for Bonfire.Common.ExtensionModule.declared_extension/0
.
Checks if outgoing federation is enabled for the given subject.
Checks if federation is generally enabled for the given subject.
Determines if the given thing is local to the current instance.
Returns the configured mailer module.
Executes a query and returns results based on the specified options.
Attempts to federate an activity based on the given parameters.
Federates an activity (if enabled) and wraps it with additional metadata.
Returns the configured repository module.
Functions
Callback implementation for Bonfire.Common.ExtensionModule.declared_extension/0
.
Checks if outgoing federation is enabled for the given subject.
Parameters
- subject: The subject to check for federation capability (optional).
Examples
iex> Bonfire.Social.federate_outgoing?()
true
iex> Bonfire.Social.federate_outgoing?(user)
false
Checks if federation is generally enabled for the given subject.
Parameters
- subject: The subject to check for federation capability (optional).
Examples
iex> Bonfire.Social.federating?()
true
iex> Bonfire.Social.federating?(user)
true
Determines if the given thing is local to the current instance.
Parameters
- thing: The object to check for locality.
- opts: Additional options for the check (optional).
Examples
iex> Bonfire.Social.is_local?(local_user)
true
iex> Bonfire.Social.is_local?(remote_user)
false
Returns the configured mailer module.
Executes a query and returns results based on the specified options.
This function can return query results in various formats, including raw query, stream, or paginated results.
Parameters
- query: The Ecto query to execute.
- paginate?: Boolean indicating whether to paginate results.
- opts: Additional options for query execution.
Examples
iex> query = from(u in User, where: u.age > 18)
iex> Bonfire.Social.many(query, false, return: :query)
#Ecto.Query<...>
iex> Bonfire.Social.many(query, true, after: "1")
%{entries: [%User{}, ...], page_info: %{...}}
maybe_federate(subject, verb, object, activity \\ nil, opts \\ [])
View SourceAttempts to federate an activity based on the given parameters.
This function handles various patterns of activities and objects, attempting to federate them according to the specified verb and options.
Parameters
- subject: The subject initiating the federation.
- verb: The verb describing the activity (e.g., :create, :delete).
- object: The object to be federated.
- activity: The associated activity data (optional).
- opts: Additional options for federation.
Examples
iex> subject = %User{id: 1}
iex> object = %Post{id: 2, content: "Hello, world!"}
iex> Bonfire.Social.maybe_federate(subject, :create, object)
{:ok, %ActivityPub.Object{}}
maybe_federate_and_gift_wrap_activity(subject, object, opts \\ [])
View SourceFederates an activity (if enabled) and wraps it with additional metadata.
This function attempts to federate an activity and, if successful, merges the federated activity information with the original object.
Parameters
- subject: The subject initiating the federation.
- object: The object to be federated.
- opts: Optional parameters for federation.
Examples
iex> subject = %User{id: 1}
iex> object = %Post{id: 2, content: "Hello, world!"}
iex> {:ok, wrapped_object} = Bonfire.Social.maybe_federate_and_gift_wrap_activity(subject, object)
iex> Map.has_key?(wrapped_object, :activity)
true
Returns the configured repository module.
Examples
iex> Bonfire.Social.repo()
Bonfire.Common.Repo