Merge branch 'bugfix/inbox-misleading-warning' into 'develop'
activity_pub_controller: Fix misleading debug warning in post_inbox_fallback See merge request pleroma/pleroma!3531
This commit is contained in:
commit
0f8b10ff5a
1 changed files with 17 additions and 20 deletions
|
@ -283,15 +283,29 @@ def inbox(%{assigns: %{valid_signature: true}} = conn, params) do
|
||||||
json(conn, "ok")
|
json(conn, "ok")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def inbox(%{assigns: %{valid_signature: false}} = conn, _params) do
|
||||||
|
conn
|
||||||
|
|> put_status(:bad_request)
|
||||||
|
|> json("Invalid HTTP Signature")
|
||||||
|
end
|
||||||
|
|
||||||
# POST /relay/inbox -or- POST /internal/fetch/inbox
|
# POST /relay/inbox -or- POST /internal/fetch/inbox
|
||||||
def inbox(conn, params) do
|
def inbox(conn, %{"type" => "Create"} = params) do
|
||||||
if params["type"] == "Create" && FederatingPlug.federating?() do
|
if FederatingPlug.federating?() do
|
||||||
post_inbox_relayed_create(conn, params)
|
post_inbox_relayed_create(conn, params)
|
||||||
else
|
else
|
||||||
post_inbox_fallback(conn, params)
|
conn
|
||||||
|
|> put_status(:bad_request)
|
||||||
|
|> json("Not federating")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def inbox(conn, _params) do
|
||||||
|
conn
|
||||||
|
|> put_status(:bad_request)
|
||||||
|
|> json("error, missing HTTP Signature")
|
||||||
|
end
|
||||||
|
|
||||||
defp post_inbox_relayed_create(conn, params) do
|
defp post_inbox_relayed_create(conn, params) do
|
||||||
Logger.debug(
|
Logger.debug(
|
||||||
"Signature missing or not from author, relayed Create message, fetching object from source"
|
"Signature missing or not from author, relayed Create message, fetching object from source"
|
||||||
|
@ -302,23 +316,6 @@ defp post_inbox_relayed_create(conn, params) do
|
||||||
json(conn, "ok")
|
json(conn, "ok")
|
||||||
end
|
end
|
||||||
|
|
||||||
defp post_inbox_fallback(conn, params) do
|
|
||||||
headers = Enum.into(conn.req_headers, %{})
|
|
||||||
|
|
||||||
if headers["signature"] && params["actor"] &&
|
|
||||||
String.contains?(headers["signature"], params["actor"]) do
|
|
||||||
Logger.debug(
|
|
||||||
"Signature validation error for: #{params["actor"]}, make sure you are forwarding the HTTP Host header!"
|
|
||||||
)
|
|
||||||
|
|
||||||
Logger.debug(inspect(conn.req_headers))
|
|
||||||
end
|
|
||||||
|
|
||||||
conn
|
|
||||||
|> put_status(:bad_request)
|
|
||||||
|> json(dgettext("errors", "error"))
|
|
||||||
end
|
|
||||||
|
|
||||||
defp represent_service_actor(%User{} = user, conn) do
|
defp represent_service_actor(%User{} = user, conn) do
|
||||||
with {:ok, user} <- User.ensure_keys_present(user) do
|
with {:ok, user} <- User.ensure_keys_present(user) do
|
||||||
conn
|
conn
|
||||||
|
|
Loading…
Reference in a new issue