Update
This commit is contained in:
parent
188bc08494
commit
4af88f3e1d
44 changed files with 1041 additions and 34 deletions
32
lib/nulla_web/controllers/generic/webfinger_controller.ex
Normal file
32
lib/nulla_web/controllers/generic/webfinger_controller.ex
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue