Merge branch 'bugfix/remote-user-atom' into 'develop'
feed/user_controller: Return 404 when the user is remote Closes #1911 See merge request pleroma/pleroma!2811
This commit is contained in:
commit
de5c7e20a3
|
@ -47,7 +47,7 @@ def feed(conn, %{"nickname" => nickname} = params) do
|
||||||
"atom"
|
"atom"
|
||||||
end
|
end
|
||||||
|
|
||||||
with {_, %User{} = user} <- {:fetch_user, User.get_cached_by_nickname(nickname)} do
|
with {_, %User{local: true} = user} <- {:fetch_user, User.get_cached_by_nickname(nickname)} do
|
||||||
activities =
|
activities =
|
||||||
%{
|
%{
|
||||||
type: ["Create"],
|
type: ["Create"],
|
||||||
|
@ -71,6 +71,7 @@ def errors(conn, {:error, :not_found}) do
|
||||||
render_error(conn, :not_found, "Not found")
|
render_error(conn, :not_found, "Not found")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def errors(conn, {:fetch_user, %User{local: false}}), do: errors(conn, {:error, :not_found})
|
||||||
def errors(conn, {:fetch_user, nil}), do: errors(conn, {:error, :not_found})
|
def errors(conn, {:fetch_user, nil}), do: errors(conn, {:error, :not_found})
|
||||||
|
|
||||||
def errors(conn, _) do
|
def errors(conn, _) do
|
||||||
|
|
|
@ -181,6 +181,17 @@ test "returns feed with public and unlisted activities", %{conn: conn} do
|
||||||
|
|
||||||
assert activity_titles == ['public', 'unlisted']
|
assert activity_titles == ['public', 'unlisted']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "returns 404 when the user is remote", %{conn: conn} do
|
||||||
|
user = insert(:user, local: false)
|
||||||
|
|
||||||
|
{:ok, _} = CommonAPI.post(user, %{status: "test"})
|
||||||
|
|
||||||
|
assert conn
|
||||||
|
|> put_req_header("accept", "application/atom+xml")
|
||||||
|
|> get(user_feed_path(conn, :feed, user.nickname))
|
||||||
|
|> response(404)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Note: see ActivityPubControllerTest for JSON format tests
|
# Note: see ActivityPubControllerTest for JSON format tests
|
||||||
|
|
Loading…
Reference in New Issue