start poking at webfinger

This commit is contained in:
Arne Brasseur 2022-12-11 15:06:47 +01:00
parent 9bdd84273e
commit bf25b247d9
5 changed files with 46 additions and 8 deletions

View file

@ -31,7 +31,8 @@
org.slf4j/log4j-over-slf4j {:exclusions [org.slf4j/slf4j-nop], :mvn/version "2.0.3"}
ch.qos.logback/logback-classic {:exclusions [org.slf4j/slf4j-api org.slf4j/slf4j-nop] :mvn/version "1.4.4"}
djblue/portal {:mvn/version "0.35.0"}}
djblue/portal {:mvn/version "0.35.0"}
lambdaisland/uri {:mvn/version "1.13.95"}}
:aliases
{:dev {:extra-paths ["dev"]}

View file

@ -1,8 +1,8 @@
(ns repl-sessions.json-ld-stuff
(:require
[cheshire.core :as json]
[clojure.string :as str]
[hato.client :as hato]
[cheshire.core :as json])
[hato.client :as hato])
(:import (org.jsoup Jsoup)))
(set! *print-namespace-maps* false)

View file

@ -7,13 +7,13 @@
(let [{:keys [schema ds]} (user/value :storage/db)
table :activitystreams/Actor
person (ap/GET "https://toot.cat/users/plexus/")]
#_
(jdbc/execute! ds
(db/insert-sql table
(select-keys person (get schema table))
(apply dissoc person :rdf/type (get schema table))))
[(select-keys person (get schema table))
(apply dissoc person :rdf/type (get schema table))]
#_[(select-keys person (get schema table))
(apply dissoc person :rdf/type (get schema table))]
)
(count

View file

@ -0,0 +1,37 @@
(ns repl-sessions.webfinger
(:require
[cheshire.core :as json]
[clojure.string :as str]
[hato.client :as hato]
[lambdaisland.uri :as uri]))
;; all of these work
"acct:plexus@toot.cat"
"http://toot.cat/@plexus"
"https://toot.cat/@plexus"
"http://toot.cat/users/plexus"
"https://toot.cat/users/plexus"
;; rel seems to be ignored
(defn fetch-webfinger [domain resource]
(-> (uri/uri "https:///.well-known/webfinger")
(assoc :host domain)
(uri/assoc-query :resource resource)
str
(hato/get {:as :json})
:body))
(fetch-webfinger "toot.cat" "acct:plexus@toot.cat")
{:subject "acct:plexus@toot.cat",
:aliases ["https://toot.cat/@plexus" "https://toot.cat/users/plexus"],
:links
[{:rel "http://webfinger.net/rel/profile-page",
:type "text/html",
:href "https://toot.cat/@plexus"}
{:rel "self",
:type "application/activity+json",
:href "https://toot.cat/users/plexus"}
{:rel "http://ostatus.org/schema/1.0/subscribe",
:template "https://toot.cat/authorize_interaction?uri={uri}"}]}

View file

@ -65,8 +65,8 @@
(cons
(json/encode props)
(concat
(map (comp pg-coerce val) props)
(map (comp pg-coerce val) props)))))
(map (comp pg-coerce val) entity)
(map (comp pg-coerce val) entity)))))
(defn start! [{:keys [props]}]
(let [ds (doto (ComboPooledDataSource.)