This commit is contained in:
Mirai Kumiko 2025-07-05 15:20:40 +02:00
parent 188bc08494
commit 4af88f3e1d
Signed by: miraikumiko
GPG key ID: 3F178B1B5E0CB278
44 changed files with 1041 additions and 34 deletions

View file

@ -0,0 +1,32 @@
defmodule NullaWeb.Generic.WebfingerController do
use NullaWeb, :controller
alias Nulla.Actors
alias Nulla.Actors.Actor
alias NullaWeb.Generic.WebfingerJSON
def index(conn, %{"resource" => resource}) do
case Regex.run(~r/^acct:(.+)$/, resource) do
[_, acct] ->
case Actors.get_actor_by(acct: acct) do
nil ->
conn
|> put_resp_content_type("text/plain")
|> send_resp(404, "")
%Actor{} = actor ->
json(conn, WebfingerJSON.show(actor))
end
_ ->
conn
|> put_resp_content_type("text/plain")
|> send_resp(400, "")
end
end
def index(conn, _params) do
conn
|> put_resp_content_type("text/plain")
|> send_resp(400, "")
end
end