Update webfinger
This commit is contained in:
parent
6be24c9544
commit
39be25bf3c
2 changed files with 33 additions and 14 deletions
|
@ -5,13 +5,13 @@ defmodule NullaWeb.WebfingerController do
|
|||
alias Nulla.Models.InstanceSettings
|
||||
|
||||
def index(conn, %{"resource" => resource}) do
|
||||
case Regex.run(~r/^acct:([^@]+)@(.+)$/, resource) do
|
||||
case Regex.run(~r/^acct:(.+)@(.+)$/, resource) do
|
||||
[_, username, domain] ->
|
||||
case Actor.get_actor(username, domain) do
|
||||
nil ->
|
||||
conn
|
||||
|> put_status(:not_found)
|
||||
|> json(%{error: "Not Found"})
|
||||
|> put_resp_content_type("text/plain")
|
||||
|> send_resp(404, "")
|
||||
|
||||
%Actor{} = actor ->
|
||||
instance_settings = InstanceSettings.get_instance_settings!()
|
||||
|
@ -20,15 +20,21 @@ defmodule NullaWeb.WebfingerController do
|
|||
json(conn, ActivityPub.webfinger(actor))
|
||||
else
|
||||
conn
|
||||
|> put_status(:not_found)
|
||||
|> json(%{error: "Not Found"})
|
||||
|> put_resp_content_type("text/plain")
|
||||
|> send_resp(404, "")
|
||||
end
|
||||
end
|
||||
|
||||
_ ->
|
||||
conn
|
||||
|> put_status(:bad_request)
|
||||
|> json(%{error: "Bad Request"})
|
||||
|> 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