mirror of
https://git.pleroma.social/sjw/pleroma.git
synced 2024-11-17 09:17:49 +01:00
Merge branch 'userfeed-fe-fallback' into 'develop'
UserController: fall back to frontend when user isn't found Closes #2730 See merge request pleroma/pleroma!3515
This commit is contained in:
commit
bd77243981
@ -18,6 +18,8 @@ defmodule Pleroma.Web.Feed.UserController do
|
||||
def feed_redirect(%{assigns: %{format: "html"}} = conn, %{"nickname" => nickname}) do
|
||||
with {_, %User{} = user} <- {:fetch_user, User.get_cached_by_nickname_or_id(nickname)} do
|
||||
Pleroma.Web.Fallback.RedirectController.redirector_with_meta(conn, %{user: user})
|
||||
else
|
||||
_ -> Pleroma.Web.Fallback.RedirectController.redirector(conn, nil)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -196,13 +196,26 @@ defmodule Pleroma.Web.Feed.UserControllerTest do
|
||||
).resp_body
|
||||
end
|
||||
|
||||
test "with html format, it returns error when user is not found", %{conn: conn} do
|
||||
test "with html format, it falls back to frontend when user is remote", %{conn: conn} do
|
||||
user = insert(:user, local: false)
|
||||
|
||||
{:ok, _} = CommonAPI.post(user, %{status: "test"})
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/users/#{user.nickname}")
|
||||
|> response(200)
|
||||
|
||||
assert response =~ "</html>"
|
||||
end
|
||||
|
||||
test "with html format, it falls back to frontend when user is not found", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> get("/users/jimm")
|
||||
|> json_response(404)
|
||||
|> response(200)
|
||||
|
||||
assert response == %{"error" => "Not found"}
|
||||
assert response =~ "</html>"
|
||||
end
|
||||
|
||||
test "with non-html / non-json format, it redirects to user feed in atom format", %{
|
||||
|
Loading…
Reference in New Issue
Block a user