Change structure
This commit is contained in:
parent
01c2c57933
commit
ddfb58c041
16 changed files with 153 additions and 66 deletions
|
@ -0,0 +1,39 @@
|
|||
defmodule NullaWeb.ActivityPub.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
|
Loading…
Add table
Add a link
Reference in a new issue