fixed connection dying error
This commit is contained in:
parent
fcbd2e9472
commit
cd26855661
|
@ -22,7 +22,7 @@ defmodule Vonbraun.ActivityPub.Handler do
|
||||||
@spec handle(%{type: String.t()}, map()) :: :ok | {:ok, atom()} | {:error, any()}
|
@spec handle(%{type: String.t()}, map()) :: :ok | {:ok, atom()} | {:error, any()}
|
||||||
def handle(activity = %{"type" => type}, actor = %{}) when is_binary(type) do
|
def handle(activity = %{"type" => type}, actor = %{}) when is_binary(type) do
|
||||||
Agent.get(__MODULE__, fn map ->
|
Agent.get(__MODULE__, fn map ->
|
||||||
func = Map.get(map, type, fn _ -> {:error, :type} end)
|
func = Map.get(map, type, fn _, _ -> {:ok, :type} end)
|
||||||
apply(func, [activity, actor])
|
apply(func, [activity, actor])
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,7 @@ defmodule Vonbraun.InboxRouter do
|
||||||
end
|
end
|
||||||
|
|
||||||
post "/" do
|
post "/" do
|
||||||
{:ok, body, _conn} = Plug.Conn.read_body(conn)
|
{:ok, body, conn} = Plug.Conn.read_body(conn)
|
||||||
Logger.debug("Got inbox POST: #{body}")
|
Logger.debug("Got inbox POST: #{body}")
|
||||||
|
|
||||||
cond do
|
cond do
|
||||||
|
@ -51,19 +51,24 @@ defmodule Vonbraun.InboxRouter do
|
||||||
200
|
200
|
||||||
end
|
end
|
||||||
|
|
||||||
send_resp(conn, status_code, "boop")
|
Logger.debug("Sending reply...")
|
||||||
|
conn = send_resp(conn, status_code, "boop")
|
||||||
|
halt(conn)
|
||||||
else
|
else
|
||||||
{:actor_url, {:ok, %{"type" => "Delete"}}} ->
|
{:actor_url, {:ok, %{"type" => "Delete"}}} ->
|
||||||
Logger.debug("Ignoring deletes right now.")
|
Logger.debug("Ignoring deletes right now.")
|
||||||
send_resp(conn, 200, "boop")
|
conn = send_resp(conn, 200, "boop")
|
||||||
|
halt(conn)
|
||||||
|
|
||||||
error ->
|
error ->
|
||||||
Logger.warning("Some kind of failure: #{inspect(error)}")
|
Logger.warning("Some kind of failure: #{inspect(error)}")
|
||||||
send_resp(conn, 500, "I fucked up")
|
conn = send_resp(conn, 500, "I fucked up")
|
||||||
|
halt(conn)
|
||||||
end
|
end
|
||||||
|
|
||||||
true ->
|
true ->
|
||||||
send_resp(conn, 404, "fuck off")
|
conn = send_resp(conn, 404, "fuck off")
|
||||||
|
halt(conn)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue