postland/lib/activity_pub/webfinger.ex

23 lines
446 B
Elixir
Raw Normal View History

2024-10-14 01:02:59 +00:00
defmodule ActivityPub.Webfinger do
def lookup_resource(acct_handle) do
[_handle, domain] = String.split(acct_handle, "@")
uri = %URI{
scheme: "https",
authority: domain,
host: domain,
port: 443,
path: "/.well-known/webfinger",
query: "resource=acct:#{acct_handle}"
}
case Req.get(uri) do
{:ok, response} ->
{:ok, response.body}
other ->
other
end
end
end