Redirect non-local activities when /notice/:id is used

Related-to: https://git.pleroma.social/pleroma/pleroma/-/issues/2496
This commit is contained in:
Haelwenn (lanodan) Monnier 2021-02-03 17:53:09 +01:00
commit ecff027418
No known key found for this signature in database
GPG key ID: D5B7A8E43C997DEE
3 changed files with 14 additions and 11 deletions

View file

@ -144,13 +144,19 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
assert redirect_url == expected_redirect_url
end
test "returns a 404 on remote notice when json requested", %{conn: conn} do
test "redirects to a proper object URL when json requested and the object is remote", %{
conn: conn
} do
note_activity = insert(:note_activity, local: false)
expected_redirect_url = Object.normalize(note_activity, fetch: false).data["id"]
conn
|> put_req_header("accept", "application/activity+json")
|> get("/notice/#{note_activity.id}")
|> response(404)
redirect_url =
conn
|> put_req_header("accept", "application/activity+json")
|> get("/notice/#{note_activity.id}")
|> redirected_to()
assert redirect_url == expected_redirect_url
end
test "500s when actor not found", %{conn: conn} do