2024-09-26 01:45:10 +00:00
|
|
|
defmodule PostlandWeb.InboxController do
|
|
|
|
|
use PostlandWeb, :controller
|
|
|
|
|
|
|
|
|
|
require Logger
|
|
|
|
|
|
|
|
|
|
alias ActivityPub.Headers
|
|
|
|
|
alias Postland.Activities
|
|
|
|
|
|
|
|
|
|
def post(conn, params) do
|
|
|
|
|
if Headers.verify(conn.method, conn.request_path, conn.req_headers) do
|
2024-10-09 22:45:28 +00:00
|
|
|
case Activities.process_activity(params) do
|
2024-09-26 01:45:10 +00:00
|
|
|
{:ok, _activity} ->
|
2024-10-10 02:01:30 +00:00
|
|
|
Plug.Conn.send_resp(conn, 200, Jason.encode!(params))
|
2024-09-26 01:45:10 +00:00
|
|
|
error ->
|
|
|
|
|
Logger.error(error)
|
2024-10-10 02:01:30 +00:00
|
|
|
Plug.Conn.send_resp(conn, 422, "unprocessable entity")
|
2024-09-26 01:45:10 +00:00
|
|
|
end
|
|
|
|
|
else
|
2024-10-10 02:01:30 +00:00
|
|
|
Plug.Conn.send_resp(conn, 403, "forbidden")
|
2024-09-26 01:45:10 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|