Bonfire.Social.Quotes (Bonfire v1.0.0-social-rc.2.20)
View SourceHandles quote post requests and approvals following FEP-044f.
Provides functionality for requesting permission to quote posts, accepting/rejecting requests, and verifying quote authorizations.
Summary
Functions
Creates quote requests for pending quotes after the post has been created.
Callback implementation for Bonfire.Federate.ActivityPub.FederationModules.federation_module/0
.
Fetches the QuoteAuthorization for a quote post using fresh data.
Requests permission to quote a post, checking boundaries and creating requests as needed.
Rejects a quote request.
Checks if a quote request has been made.
Verifies that a quote authorization is valid.
Functions
Creates quote requests for pending quotes after the post has been created.
Callback implementation for Bonfire.Federate.ActivityPub.FederationModules.federation_module/0
.
Fetches the QuoteAuthorization for a quote post using fresh data.
Parameters
quote_post
: The quote post to get authorization forquoted_object
: The quoted object (optional - if not provided, gets first quoted object)
Returns
{:ok, authorization}
if found, {:error, :not_found}
otherwise.
Examples
iex> fetch_fresh_quote_authorization(quote_post)
{:ok, %ActivityPub.Object{}}
iex> fetch_fresh_quote_authorization(quote_post, quoted_object)
{:ok, %ActivityPub.Object{}}
Requests permission to quote a post, checking boundaries and creating requests as needed.
Returns a tuple with {approved_quotes, pending_quotes} where:
- approved_quotes can be tagged immediately
- pending_quotes need quote requests after post creation
Rejects a quote request.
Parameters
request
: The request to ignoreopts
: Additional options
Returns
Result of the ignore operation.
Examples
iex> reject(request, current_user: user)
{:ok, ignored_request}
Checks if a quote request has been made.
Parameters
subject
: The subject (requester)quote_post
: The quote post (instrument)quoted_object
: The quoted object
Returns
Boolean indicating if a quote request exists.
Examples
iex> Bonfire.Social.Quotes.requested?(user, quote_post, quoted_object)
true
Verifies that a quote authorization is valid.
Parameters
quote_post
: The quote post to verify authorization forquoted_object
: The quoted object (optional - will call get_quote_authorization to get it)
Returns
{:ok, :valid}
if authorization exists and is valid{:error, :invalid}
if authorization exists but is invalid (wrong signatures, etc){:error, :revoked}
if authorization was deleted/revoked or network errors
Examples
iex> Bonfire.Social.Quotes.verify_quote_authorization(quote_post)
{:ok, :valid}
iex> Bonfire.Social.Quotes.verify_quote_authorization(quote_post, quoted_object)
{:error, :invalid}