Merge pull request 'Do not try to redirect to post display URLs for non-Create activities' (#997) from Oneric/akkoma:fix-non-create-html-redirect into develop
Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/997
This commit is contained in:
commit
862fba5ac5
2 changed files with 22 additions and 0 deletions
|
|
@ -56,6 +56,7 @@ def activity(%{assigns: %{format: format}} = conn, _params)
|
|||
def activity(conn, _params) do
|
||||
with id <- Endpoint.url() <> conn.request_path,
|
||||
{_, %Activity{} = activity} <- {:activity, Activity.normalize(id)},
|
||||
{_, "Create"} <- {:type, activity.data["type"]},
|
||||
{_, true} <- {:public?, Visibility.is_public?(activity)},
|
||||
{_, false} <- {:local_public?, Visibility.is_local_public?(activity)} do
|
||||
redirect(conn, to: "/notice/#{activity.id}")
|
||||
|
|
@ -63,6 +64,9 @@ def activity(conn, _params) do
|
|||
reason when reason in [{:public?, false}, {:activity, nil}] ->
|
||||
{:error, :not_found}
|
||||
|
||||
{:type, _} ->
|
||||
{:error, :not_found}
|
||||
|
||||
e ->
|
||||
e
|
||||
end
|
||||
|
|
|
|||
|
|
@ -126,6 +126,24 @@ test "404s on nonexistent activities", %{conn: conn} do
|
|||
|> get("/activities/123")
|
||||
|> response(404)
|
||||
end
|
||||
|
||||
test "404s on non-Create activities", %{conn: conn} do
|
||||
activity = insert(:note_activity)
|
||||
like_user = insert(:user)
|
||||
|
||||
{:ok, like_activity} = CommonAPI.favorite(like_user, activity.id)
|
||||
|
||||
like_url_path =
|
||||
like_activity.data["id"]
|
||||
|> String.trim_leading(Pleroma.Web.Endpoint.url())
|
||||
|
||||
assert String.starts_with?(like_url_path, "/activities/")
|
||||
assert Pleroma.Web.Endpoint.url() <> like_url_path == like_activity.data["id"]
|
||||
|
||||
conn
|
||||
|> get(like_url_path)
|
||||
|> response(404)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET notice/2" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue