bonfire-app/ActivityPub.Utils.html
2024-04-16 21:21:08 +00:00

1349 lines
39 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="ExDoc v0.31.2">
<meta name="project" content="bonfire_umbrella v0.9.10-cooperation-beta.62">
<title>ActivityPub.Utils — bonfire_umbrella v0.9.10-cooperation-beta.62</title>
<link rel="stylesheet" href="dist/html-elixir-JKHCEBPC.css" />
<script src="dist/handlebars.runtime-NWIB6V2M.js"></script>
<script src="dist/handlebars.templates-A7S2WMC7.js"></script>
<script src="dist/sidebar_items-0AD831F9.js"></script>
<script src="docs_config.js"></script>
<script async src="dist/html-JRPQ5PR6.js"></script>
</head>
<body data-type="modules" class="page-module">
<script>
try {
var settings = JSON.parse(localStorage.getItem('ex_doc:settings') || '{}');
if (settings.theme === 'dark' ||
((settings.theme === 'system' || settings.theme == null) &&
window.matchMedia('(prefers-color-scheme: dark)').matches)
) {
document.body.classList.add('dark')
}
} catch (error) { }
</script>
<div class="main">
<button id="sidebar-menu" class="sidebar-button sidebar-toggle" aria-label="toggle sidebar" aria-controls="sidebar">
<i class="ri-menu-line ri-lg" title="Collapse/expand sidebar"></i>
</button>
<div class="background-layer"></div>
<nav id="sidebar" class="sidebar">
<div class="sidebar-header">
<div class="sidebar-projectInfo">
<a href="https://bonfirenetworks.org" class="sidebar-projectImage">
<img src="assets/logo.png" alt="bonfire_umbrella" />
</a>
<div>
<a href="https://bonfirenetworks.org" class="sidebar-projectName" translate="no">
bonfire_umbrella
</a>
<div class="sidebar-projectVersion" translate="no">
v0.9.10-cooperation-beta.62
</div>
</div>
</div>
<ul id="sidebar-listNav" class="sidebar-listNav" role="tablist">
<li>
<button id="extras-list-tab-button" role="tab" data-type="extras" aria-controls="extras-tab-panel" aria-selected="true" tabindex="0">
Pages
</button>
</li>
<li>
<button id="modules-list-tab-button" role="tab" data-type="modules" aria-controls="modules-tab-panel" aria-selected="false" tabindex="-1">
Modules
</button>
</li>
</ul>
</div>
<div id="extras-tab-panel" class="sidebar-tabpanel" role="tabpanel" aria-labelledby="extras-list-tab-button">
<ul id="extras-full-list" class="full-list"></ul>
</div>
<div id="modules-tab-panel" class="sidebar-tabpanel" role="tabpanel" aria-labelledby="modules-list-tab-button" hidden>
<ul id="modules-full-list" class="full-list"></ul>
</div>
</nav>
<main class="content">
<output role="status" id="toast"></output>
<div class="content-outer">
<div id="content" class="content-inner">
<div class="top-search">
<div class="search-settings">
<form class="search-bar" action="search.html">
<label class="search-label">
<span class="sr-only">Search documentation of bonfire_umbrella</span>
<input name="q" type="text" class="search-input" placeholder="Press / to search" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" />
</label>
<button type="submit" class="search-button" aria-label="Submit Search">
<i class="ri-search-2-line ri-lg" aria-hidden="true" title="Submit search"></i>
</button>
<button type="button" tabindex="-1" class="search-close-button" aria-hidden="true">
<i class="ri-close-line ri-lg" title="Cancel search"></i>
</button>
</form>
<div class="autocomplete">
</div>
<button class="icon-settings display-settings">
<i class="ri-settings-3-line"></i>
<span class="sr-only">Settings</span>
</button>
</div>
</div>
<h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L1" title="View Source" class="icon-action" rel="help">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
<span translate="no">ActivityPub.Utils</span>
<small class="app-vsn" translate="no">(bonfire_umbrella v0.9.10-cooperation-beta.62)</small>
</h1>
<section id="moduledoc">
<p>Misc functions used for federation</p>
</section>
<section id="summary" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#summary">
<i class="ri-link-m" aria-hidden="true"></i>
</a>
<span class="text">Summary</span>
</h1>
<div class="summary-functions summary">
<h2>
<a href="#functions">Functions</a>
</h2>
<div class="summary-row">
<div class="summary-signature">
<a href="#activitypub_object_headers/0" translate="no">activitypub_object_headers()</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#adapter_fallback/0" translate="no">adapter_fallback()</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#ap_base_url/0" translate="no">ap_base_url()</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#ap_id/1" translate="no">ap_id(map)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#as_local_public/0" translate="no">as_local_public()</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#cache_clear/0" translate="no">cache_clear()</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#cachex_fetch/4" translate="no">cachex_fetch(cache, key, fallback, options \\ [])</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#error_json/3" translate="no">error_json(conn, error, status \\ 500)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#format_date/1" translate="no">format_date(date \\ NaiveDateTime.utc_now(Calendar.ISO))</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#generate_id/1" translate="no">generate_id(type)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#generate_object_id/0" translate="no">generate_object_id()</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#get_with_cache/4" translate="no">get_with_cache(get_fun, cache_bucket, key, identifier)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#has_as_public?/1" translate="no">has_as_public?(tos)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#is_ulid?/1" translate="no">is_ulid?(str)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#is_uuid?/1" translate="no">is_uuid?(str)</a>
</div>
<div class="summary-synopsis"><p>Takes a string and returns true if it is a valid UUID (Universally Unique Identifier)</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#json_with_cache/6" translate="no">json_with_cache(conn \\ nil, get_fun, cache_bucket, id, ret_fn \\ &amp;return_json/4, opts \\ [])</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#label_in_collection?/2" translate="no">label_in_collection?(label, collection)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#make_date/0" translate="no">make_date()</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#make_json_ld_header/1" translate="no">make_json_ld_header(type \\ :object)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#maybe_put/3" translate="no">maybe_put(map, key, value)</a>
</div>
<div class="summary-synopsis"><p>conditionally update a map</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#maybe_to_atom/1" translate="no">maybe_to_atom(str)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#maybe_to_string/1" translate="no">maybe_to_string(atom)</a>
</div>
<div class="summary-synopsis"><p>Handles multiple cases where the input value is of a different type (atom, list, tuple, etc.) and returns a string representation of it.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#ok_unwrap/2" translate="no">ok_unwrap(val, fallback \\ nil)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#public?/1" translate="no">public?(params)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#public?/2" translate="no">public?(activity_data, object_data)</a>
</div>
<div class="summary-synopsis"><p>Determines if an object or an activity is public.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#put_if_present/4" translate="no">put_if_present(map, key, value, value_function \\ &amp;{:ok, &amp;1})</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#repo/0" translate="no">repo()</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#request_ip/1" translate="no">request_ip(remote_ip)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#return_json/4" translate="no">return_json(conn, meta, json, opts \\ [])</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#safe_put_in/3" translate="no">safe_put_in(data, keys, value)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#service_actor/0" translate="no">service_actor()</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#service_actor!/0" translate="no">service_actor!()</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#set_repo/1" translate="no">set_repo(repo)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#single_ap_id/1" translate="no">single_ap_id(ap_id)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#single_ap_id_or_object/1" translate="no">single_ap_id_or_object(ap_id)</a>
</div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#stringify_keys/2" translate="no">stringify_keys(map, recursive \\ false)</a>
</div>
<div class="summary-synopsis"><p>Takes a map or keyword list, and returns a map with any atom keys converted to string keys. It can optionally do so recursively.</p></div>
</div>
<div class="summary-row">
<div class="summary-signature">
<a href="#ulid/1" translate="no">ulid(input)</a>
</div>
</div>
</div>
</section>
<section id="functions" class="details-list">
<h1 class="section-heading">
<a class="hover-link" href="#functions">
<i class="ri-link-m" aria-hidden="true"></i>
</a>
<span class="text">Functions</span>
</h1>
<div class="functions-list">
<section class="detail" id="activitypub_object_headers/0">
<div class="detail-header">
<a href="#activitypub_object_headers/0" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">activitypub_object_headers()</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L44" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="adapter_fallback/0">
<div class="detail-header">
<a href="#adapter_fallback/0" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">adapter_fallback()</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L16" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="ap_base_url/0">
<div class="detail-header">
<a href="#ap_base_url/0" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">ap_base_url()</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L40" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="ap_id/1">
<div class="detail-header">
<a href="#ap_id/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">ap_id(map)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L176" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="as_local_public/0">
<div class="detail-header">
<a href="#as_local_public/0" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">as_local_public()</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L28" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="cache_clear/0">
<div class="detail-header">
<a href="#cache_clear/0" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">cache_clear()</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L241" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="cachex_fetch/4">
<span id="cachex_fetch/3"></span>
<div class="detail-header">
<a href="#cachex_fetch/4" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">cachex_fetch(cache, key, fallback, options \\ [])</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L221" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="error_json/3">
<span id="error_json/2"></span>
<div class="detail-header">
<a href="#error_json/3" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">error_json(conn, error, status \\ 500)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L391" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="format_date/1">
<span id="format_date/0"></span>
<div class="detail-header">
<a href="#format_date/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">format_date(date \\ NaiveDateTime.utc_now(Calendar.ISO))</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L557" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="generate_id/1">
<div class="detail-header">
<a href="#generate_id/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">generate_id(type)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L38" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="generate_object_id/0">
<div class="detail-header">
<a href="#generate_object_id/0" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">generate_object_id()</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L36" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="get_with_cache/4">
<div class="detail-header">
<a href="#get_with_cache/4" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">get_with_cache(get_fun, cache_bucket, key, identifier)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L255" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="has_as_public?/1">
<div class="detail-header">
<a href="#has_as_public?/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">has_as_public?(tos)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L126" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="is_ulid?/1">
<div class="detail-header">
<a href="#is_ulid?/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">is_ulid?(str)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L154" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="is_uuid?/1">
<div class="detail-header">
<a href="#is_uuid?/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">is_uuid?(str)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L145" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Takes a string and returns true if it is a valid UUID (Universally Unique Identifier)</p>
</section>
</section>
<section class="detail" id="json_with_cache/6">
<span id="json_with_cache/3"></span>
<span id="json_with_cache/4"></span>
<span id="json_with_cache/5"></span>
<div class="detail-header">
<a href="#json_with_cache/6" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">json_with_cache(conn \\ nil, get_fun, cache_bucket, id, ret_fn \\ &amp;return_json/4, opts \\ [])</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L336" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="label_in_collection?/2">
<div class="detail-header">
<a href="#label_in_collection?/2" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">label_in_collection?(label, collection)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L136" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<div class="specs">
<pre translate="no"><span class="attribute">@spec</span> label_in_collection?(<a href="https://hexdocs.pm/elixir/String.html#t:t/0">String.t</a>(), <a href="https://hexdocs.pm/elixir/typespecs.html#basic-types">map</a>()) :: <a href="https://hexdocs.pm/elixir/typespecs.html#built-in-types">boolean</a>()</pre>
</div>
</section>
</section>
<section class="detail" id="make_date/0">
<div class="detail-header">
<a href="#make_date/0" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">make_date()</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L30" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="make_json_ld_header/1">
<span id="make_json_ld_header/0"></span>
<div class="detail-header">
<a href="#make_json_ld_header/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">make_json_ld_header(type \\ :object)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L46" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="maybe_put/3">
<div class="detail-header">
<a href="#maybe_put/3" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">maybe_put(map, key, value)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L398" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>conditionally update a map</p>
</section>
</section>
<section class="detail" id="maybe_to_atom/1">
<div class="detail-header">
<a href="#maybe_to_atom/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">maybe_to_atom(str)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L419" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="maybe_to_string/1">
<div class="detail-header">
<a href="#maybe_to_string/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">maybe_to_string(atom)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L540" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Handles multiple cases where the input value is of a different type (atom, list, tuple, etc.) and returns a string representation of it.</p>
</section>
</section>
<section class="detail" id="ok_unwrap/2">
<span id="ok_unwrap/1"></span>
<div class="detail-header">
<a href="#ok_unwrap/2" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">ok_unwrap(val, fallback \\ nil)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L22" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="public?/1">
<div class="detail-header">
<a href="#public?/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">public?(params)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L101" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="public?/2">
<div class="detail-header">
<a href="#public?/2" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">public?(activity_data, object_data)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L68" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Determines if an object or an activity is public.</p>
</section>
</section>
<section class="detail" id="put_if_present/4">
<span id="put_if_present/3"></span>
<div class="detail-header">
<a href="#put_if_present/4" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">put_if_present(map, key, value, value_function \\ &amp;{:ok, &amp;1})</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L403" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="repo/0">
<div class="detail-header">
<a href="#repo/0" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">repo()</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L14" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="request_ip/1">
<div class="detail-header">
<a href="#request_ip/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">request_ip(remote_ip)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L490" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="return_json/4">
<span id="return_json/3"></span>
<div class="detail-header">
<a href="#return_json/4" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">return_json(conn, meta, json, opts \\ [])</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L382" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="safe_put_in/3">
<div class="detail-header">
<a href="#safe_put_in/3" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">safe_put_in(data, keys, value)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L413" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="service_actor/0">
<div class="detail-header">
<a href="#service_actor/0" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">service_actor()</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L498" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="service_actor!/0">
<div class="detail-header">
<a href="#service_actor!/0" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">service_actor!()</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L505" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="set_repo/1">
<div class="detail-header">
<a href="#set_repo/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">set_repo(repo)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L205" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="single_ap_id/1">
<div class="detail-header">
<a href="#single_ap_id/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">single_ap_id(ap_id)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L445" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="single_ap_id_or_object/1">
<div class="detail-header">
<a href="#single_ap_id_or_object/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">single_ap_id_or_object(ap_id)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L429" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
<section class="detail" id="stringify_keys/2">
<span id="stringify_keys/1"></span>
<div class="detail-header">
<a href="#stringify_keys/2" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">stringify_keys(map, recursive \\ false)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L519" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
<p>Takes a map or keyword list, and returns a map with any atom keys converted to string keys. It can optionally do so recursively.</p>
</section>
</section>
<section class="detail" id="ulid/1">
<div class="detail-header">
<a href="#ulid/1" class="detail-link" title="Link to this function">
<i class="ri-link-m" aria-hidden="true"></i>
<span class="sr-only">Link to this function</span>
</a>
<h1 class="signature" translate="no">ulid(input)</h1>
<a href="https://github.com/bonfire-networks/activity_pub/blob/main/lib/utils.ex#L164" class="icon-action" rel="help" title="View Source">
<i class="ri-code-s-slash-line" aria-hidden="true"></i>
<span class="sr-only">View Source</span>
</a>
</div>
<section class="docstring">
</section>
</section>
</div>
</section>
<footer class="footer">
<p>
<span class="line">
<button class="a-main footer-button display-quick-switch" title="Search HexDocs packages">
Search HexDocs
</button>
<a href="bonfire_umbrella.epub" title="ePub version">
Download ePub version
</a>
</span>
</p>
<p class="built-using">
Built using
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" target="_blank" rel="help noopener" translate="no">ExDoc</a> (v0.31.2) for the
<a href="https://elixir-lang.org" title="Elixir" target="_blank" translate="no">Elixir programming language</a>
</p>
</footer>
</div>
</div>
</main>
</div>
</body>
</html>