Change structure

This commit is contained in:
Mirai Kumiko 2025-07-01 10:15:06 +02:00
parent 01c2c57933
commit ddfb58c041
Signed by: miraikumiko
GPG key ID: 3F178B1B5E0CB278
16 changed files with 153 additions and 66 deletions

View file

@ -1,39 +0,0 @@
defmodule NullaWeb.WebfingerController do
use NullaWeb, :controller
alias Nulla.ActivityPub
alias Nulla.Models.Actor
def index(conn, %{"resource" => resource}) do
case Regex.run(~r/^acct:(.+)@(.+)$/, resource) do
[_, preferredUsername, actor_domain] ->
case Actor.get_actor(preferredUsername: preferredUsername, domain: actor_domain) do
nil ->
conn
|> put_resp_content_type("text/plain")
|> send_resp(404, "")
%Actor{} = actor ->
domain = NullaWeb.Endpoint.host()
if actor_domain == domain do
json(conn, ActivityPub.webfinger(actor))
else
conn
|> put_resp_content_type("text/plain")
|> send_resp(404, "")
end
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