dog-and-duck/docs/codox/Using_ActivityPub.html
2022-12-19 23:39:24 +00:00

112 lines
14 KiB
HTML

<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>Using ActivityPub</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Dog-and-duck</span> <span class="project-version">0.1.0-SNAPSHOT</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Topics</span></h3><ul><li class="depth-1 current"><a href="Using_ActivityPub.html"><div class="inner"><span>Using ActivityPub</span></div></a></li><li class="depth-1 "><a href="intro.html"><div class="inner"><span>The Old Dog and Duck</span></div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>clj-activitypub</span></div></div></li><li class="depth-2 branch"><a href="clj-activitypub.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>internal</span></div></div></li><li class="depth-3 branch"><a href="clj-activitypub.internal.crypto.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>crypto</span></div></a></li><li class="depth-3 branch"><a href="clj-activitypub.internal.http-util.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>http-util</span></div></a></li><li class="depth-3"><a href="clj-activitypub.internal.thread-cache.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>thread-cache</span></div></a></li><li class="depth-2"><a href="clj-activitypub.webfinger.html"><div class="inner"><span class="tree" style="top: -114px;"><span class="top" style="height: 123px;"></span><span class="bottom"></span></span><span>webfinger</span></div></a></li><li class="depth-1"><div class="no-link"><div class="inner"><span class="tree" style="top: -207px;"><span class="top" style="height: 216px;"></span><span class="bottom"></span></span><span>dog-and-duck</span></div></div></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>quack</span></div></div></li><li class="depth-3"><a href="dog-and-duck.quack.quack.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>quack</span></div></a></li><li class="depth-2"><div class="no-link"><div class="inner"><span class="tree" style="top: -52px;"><span class="top" style="height: 61px;"></span><span class="bottom"></span></span><span>scratch</span></div></div></li><li class="depth-3 branch"><a href="dog-and-duck.scratch.core.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>core</span></div></a></li><li class="depth-3 branch"><a href="dog-and-duck.scratch.parser.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>parser</span></div></a></li><li class="depth-3"><a href="dog-and-duck.scratch.scratch.html"><div class="inner"><span class="tree"><span class="top"></span><span class="bottom"></span></span><span>scratch</span></div></a></li></ul></div><div class="document" id="content"><div class="doc"><div class="markdown"><h1><a href="#using-activitypub" name="using-activitypub"></a>Using ActivityPub</h1>
<pre><code class="clojure">user=&gt; (require '[clj-activitypub.core :as activitypub])
nil
user=&gt; (require '[clj-activitypub.webfinger :as webfinger])
nil
user=&gt; (require '[clojure.walk :refer [keywordize-keys]])
nil
user=&gt; (require '[clojure.pprint :refer [pprint]])
nil
user=&gt; (def base-domain "mastodon.scot")
#'user/base-domain
user=&gt; (def account-handle "@simon_brooke@mastodon.scot")
#'user/account-handle
user=&gt; (in-ns 'user)
#object[clojure.lang.Namespace 0x525575 "user"]
user=&gt; (activitypub/parse-account account-handle )
{:domain "mastodon.scot", :username "simon_brooke"}
user=&gt; (map *1 [:domain :username])
("mastodon.scot" "simon_brooke")
user=&gt; (apply webfinger/fetch-user-id *1)
"https://mastodon.scot/users/simon_brooke"
user=&gt; (activitypub/fetch-user *1)
{"followers" "https://mastodon.scot/users/simon_brooke/followers", "inbox" "https://mastodon.scot/users/simon_brooke/inbox", "url" "https://mastodon.scot/@simon_brooke", "@context" ["https://www.w3.org/ns/activitystreams" "https://w3id.org/security/v1" {"identityKey" {"@type" "@id", "@id" "toot:identityKey"}, "EncryptedMessage" "toot:EncryptedMessage", "Ed25519Key" "toot:Ed25519Key", "devices" {"@type" "@id", "@id" "toot:devices"}, "manuallyApprovesFollowers" "as:manuallyApprovesFollowers", "schema" "http://schema.org#", "PropertyValue" "schema:PropertyValue", "Curve25519Key" "toot:Curve25519Key", "claim" {"@type" "@id", "@id" "toot:claim"}, "value" "schema:value", "Hashtag" "as:Hashtag", "movedTo" {"@id" "as:movedTo", "@type" "@id"}, "discoverable" "toot:discoverable", "messageType" "toot:messageType", "messageFranking" "toot:messageFranking", "cipherText" "toot:cipherText", "toot" "http://joinmastodon.org/ns#", "alsoKnownAs" {"@id" "as:alsoKnownAs", "@type" "@id"}, "featured" {"@id" "toot:featured", "@type" "@id"}, "featuredTags" {"@id" "toot:featuredTags", "@type" "@id"}, "Ed25519Signature" "toot:Ed25519Signature", "focalPoint" {"@container" "@list", "@id" "toot:focalPoint"}, "fingerprintKey" {"@type" "@id", "@id" "toot:fingerprintKey"}, "Device" "toot:Device", "publicKeyBase64" "toot:publicKeyBase64", "deviceId" "toot:deviceId", "suspended" "toot:suspended"}], "devices" "https://mastodon.scot/users/simon_brooke/collections/devices", "manuallyApprovesFollowers" false, "image" {"type" "Image", "mediaType" "image/jpeg", "url" "https://media.mastodon.scot/mastodon-scot-public/accounts/headers/109/252/274/874/045/781/original/e1f1823c4361fa27.jpg"}, "endpoints" {"sharedInbox" "https://mastodon.scot/inbox"}, "id" "https://mastodon.scot/users/simon_brooke", "publicKey" {"id" "https://mastodon.scot/users/simon_brooke#main-key", "owner" "https://mastodon.scot/users/simon_brooke", "publicKeyPem" "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2/6GgLJgJlPhhqFm1tUQ\noSLnWxhDwq4HlZIHrBsVjkSvUAnHKqq42Q/hta+fkWB8rmTFpmjLXDj/Fi0uejvT\nBc+KrLwfX/yR8+G87afGCRS3CaumoLJ7zkBIlsFzIKMoIke1D3QuHX95yGGXs+hp\nmyxt/+CXRyZjK7u9NG7SMRUlpwvOlpD12Aei35Nb8NSr03JvY8/WVMIbWrecyI0b\nAlwj6axxHx7J15Yo+aEtKzZ2OFKXf+sh0QF9BEnYcmVKYlR6kiOglLFHKdCBUSYi\ni9Flv00TydqlGvR5fpShBqORiy0M/FVtNXlz2sNBEsGB2meipkjh+cRLzTbYo4KL\nJwIDAQAB\n-----END PUBLIC KEY-----\n"}, "summary" "&lt;p&gt;Anarcho-syndicalist, autistic, crofter, cyclist, depressive, entrepreneur, geek, Zapatista. Politics &amp;amp; environment, especially &lt;a href=\"https://mastodon.scot/tags/LandReform\" class=\"mention hashtag\" rel=\"tag\"&gt;#&lt;span&gt;LandReform&lt;/span&gt;&lt;/a&gt;. he/him.&lt;/p&gt;&lt;p&gt;Twitter: &lt;span class=\"h-card\"&gt;&lt;a href=\"https://mastodon.scot/@simon_brooke\" class=\"u-url mention\"&gt;@&lt;span&gt;simon_brooke&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;GitHub: simon-brooke&lt;br /&gt;FetLife: Simon_Brooke&lt;/p&gt;&lt;p&gt;Credo: Life is harsh. What we can do - and what we should do - is strive to make it less harsh for the people around us.&lt;/p&gt;", "attachment" [{"type" "PropertyValue", "name" "Home Page", "value" "&lt;a href=\"https://www.journeyman.cc/~simon/\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\"&gt;&lt;span class=\"invisible\"&gt;https://www.&lt;/span&gt;&lt;span class=\"\"&gt;journeyman.cc/~simon/&lt;/span&gt;&lt;span class=\"invisible\"&gt;&lt;/span&gt;&lt;/a&gt;"}], "name" "Simon Brooke", "tag" [{"type" "Hashtag", "href" "https://mastodon.scot/tags/landreform", "name" "#landreform"}], "published" "2022-10-29T00:00:00Z", "preferredUsername" "simon_brooke", "discoverable" true, "alsoKnownAs" ["https://mastodon.social/users/simon_brooke"], "featured" "https://mastodon.scot/users/simon_brooke/collections/featured", "featuredTags" "https://mastodon.scot/users/simon_brooke/collections/tags", "type" "Person", "outbox" "https://mastodon.scot/users/simon_brooke/outbox", "following" "https://mastodon.scot/users/simon_brooke/following", "icon" {"type" "Image", "mediaType" "image/png", "url" "https://media.mastodon.scot/mastodon-scot-public/accounts/avatars/109/252/274/874/045/781/original/172e8f7530627e87.png"}}
user=&gt; (def sb (keywordize-keys *1))
#'user/sb
user=&gt; (:outbox sb)
"https://mastodon.scot/users/simon_brooke/outbox"
user=&gt; (require '[clojure.data.json :as json])
nil
user=&gt; (slurp (:outbox sb))
Execution error (IOException) at sun.net.www.protocol.http.HttpURLConnection/getInputStream0 (HttpURLConnection.java:1894).
Server returned HTTP response code: 403 for URL: https://mastodon.scot/users/simon_brooke/outbox
user=&gt; (pprint sb)
{:inbox "https://mastodon.scot/users/simon_brooke/inbox",
:name "Simon Brooke",
:@context
["https://www.w3.org/ns/activitystreams"
"https://w3id.org/security/v1"
{:schema "http://schema.org#",
:messageType "toot:messageType",
:messageFranking "toot:messageFranking",
:identityKey {:@type "@id", :@id "toot:identityKey"},
:Hashtag "as:Hashtag",
:deviceId "toot:deviceId",
:publicKeyBase64 "toot:publicKeyBase64",
:value "schema:value",
:Ed25519Key "toot:Ed25519Key",
:featured {:@id "toot:featured", :@type "@id"},
:Curve25519Key "toot:Curve25519Key",
:discoverable "toot:discoverable",
:focalPoint {:@container "@list", :@id "toot:focalPoint"},
:suspended "toot:suspended",
:fingerprintKey {:@type "@id", :@id "toot:fingerprintKey"},
:Ed25519Signature "toot:Ed25519Signature",
:cipherText "toot:cipherText",
:EncryptedMessage "toot:EncryptedMessage",
:alsoKnownAs {:@id "as:alsoKnownAs", :@type "@id"},
:featuredTags {:@id "toot:featuredTags", :@type "@id"},
:devices {:@type "@id", :@id "toot:devices"},
:toot "http://joinmastodon.org/ns#",
:movedTo {:@id "as:movedTo", :@type "@id"},
:Device "toot:Device",
:PropertyValue "schema:PropertyValue",
:manuallyApprovesFollowers "as:manuallyApprovesFollowers",
:claim {:@type "@id", :@id "toot:claim"}}],
:featured
"https://mastodon.scot/users/simon_brooke/collections/featured",
:type "Person",
:discoverable true,
:icon
{:type "Image",
:mediaType "image/png",
:url
"https://media.mastodon.scot/mastodon-scot-public/accounts/avatars/109/252/274/874/045/781/original/172e8f7530627e87.png"},
:following "https://mastodon.scot/users/simon_brooke/following",
:summary
"&lt;p&gt;Anarcho-syndicalist, autistic, crofter, cyclist, depressive, entrepreneur, geek, Zapatista. Politics &amp;amp; environment, especially &lt;a href=\"https://mastodon.scot/tags/LandReform\" class=\"mention hashtag\" rel=\"tag\"&gt;#&lt;span&gt;LandReform&lt;/span&gt;&lt;/a&gt;. he/him.&lt;/p&gt;&lt;p&gt;Twitter: &lt;span class=\"h-card\"&gt;&lt;a href=\"https://mastodon.scot/@simon_brooke\" class=\"u-url mention\"&gt;@&lt;span&gt;simon_brooke&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;GitHub: simon-brooke&lt;br /&gt;FetLife: Simon_Brooke&lt;/p&gt;&lt;p&gt;Credo: Life is harsh. What we can do - and what we should do - is strive to make it less harsh for the people around us.&lt;/p&gt;",
:publicKey
{:id "https://mastodon.scot/users/simon_brooke#main-key",
:owner "https://mastodon.scot/users/simon_brooke",
:publicKeyPem
"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2/6GgLJgJlPhhqFm1tUQ\noSLnWxhDwq4HlZIHrBsVjkSvUAnHKqq42Q/hta+fkWB8rmTFpmjLXDj/Fi0uejvT\nBc+KrLwfX/yR8+G87afGCRS3CaumoLJ7zkBIlsFzIKMoIke1D3QuHX95yGGXs+hp\nmyxt/+CXRyZjK7u9NG7SMRUlpwvOlpD12Aei35Nb8NSr03JvY8/WVMIbWrecyI0b\nAlwj6axxHx7J15Yo+aEtKzZ2OFKXf+sh0QF9BEnYcmVKYlR6kiOglLFHKdCBUSYi\ni9Flv00TydqlGvR5fpShBqORiy0M/FVtNXlz2sNBEsGB2meipkjh+cRLzTbYo4KL\nJwIDAQAB\n-----END PUBLIC KEY-----\n"},
:endpoints {:sharedInbox "https://mastodon.scot/inbox"},
:preferredUsername "simon_brooke",
:id "https://mastodon.scot/users/simon_brooke",
:alsoKnownAs ["https://mastodon.social/users/simon_brooke"],
:outbox "https://mastodon.scot/users/simon_brooke/outbox",
:url "https://mastodon.scot/@simon_brooke",
:featuredTags
"https://mastodon.scot/users/simon_brooke/collections/tags",
:devices
"https://mastodon.scot/users/simon_brooke/collections/devices",
:image
{:type "Image",
:mediaType "image/jpeg",
:url
"https://media.mastodon.scot/mastodon-scot-public/accounts/headers/109/252/274/874/045/781/original/e1f1823c4361fa27.jpg"},
:tag
[{:type "Hashtag",
:href "https://mastodon.scot/tags/landreform",
:name "#landreform"}],
:followers "https://mastodon.scot/users/simon_brooke/followers",
:published "2022-10-29T00:00:00Z",
:manuallyApprovesFollowers false,
:attachment
[{:type "PropertyValue",
:name "Home Page",
:value
"&lt;a href=\"https://www.journeyman.cc/~simon/\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\"&gt;&lt;span class=\"invisible\"&gt;https://www.&lt;/span&gt;&lt;span class=\"\"&gt;journeyman.cc/~simon/&lt;/span&gt;&lt;span class=\"invisible\"&gt;&lt;/span&gt;&lt;/a&gt;"}]}
</code></pre></div></div></div></body></html>