diff --git a/lib/vonbraun/activity_pub/handler.ex b/lib/vonbraun/activity_pub/handler.ex index c9df419..a41fdf8 100644 --- a/lib/vonbraun/activity_pub/handler.ex +++ b/lib/vonbraun/activity_pub/handler.ex @@ -22,7 +22,7 @@ defmodule Vonbraun.ActivityPub.Handler do @spec handle(%{type: String.t()}, map()) :: :ok | {:ok, atom()} | {:error, any()} def handle(activity = %{"type" => type}, actor = %{}) when is_binary(type) do 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]) end) end diff --git a/lib/vonbraun/inbox_router.ex b/lib/vonbraun/inbox_router.ex index 5fafafe..d0e8fc2 100644 --- a/lib/vonbraun/inbox_router.ex +++ b/lib/vonbraun/inbox_router.ex @@ -19,7 +19,7 @@ defmodule Vonbraun.InboxRouter do end post "/" do - {:ok, body, _conn} = Plug.Conn.read_body(conn) + {:ok, body, conn} = Plug.Conn.read_body(conn) Logger.debug("Got inbox POST: #{body}") cond do @@ -51,19 +51,24 @@ defmodule Vonbraun.InboxRouter do 200 end - send_resp(conn, status_code, "boop") + Logger.debug("Sending reply...") + conn = send_resp(conn, status_code, "boop") + halt(conn) else {:actor_url, {:ok, %{"type" => "Delete"}}} -> Logger.debug("Ignoring deletes right now.") - send_resp(conn, 200, "boop") + conn = send_resp(conn, 200, "boop") + halt(conn) 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 true -> - send_resp(conn, 404, "fuck off") + conn = send_resp(conn, 404, "fuck off") + halt(conn) end end end