MastodonApi: Implement hide_network.
This commit is contained in:
parent
6be0ab1e55
commit
2a639de9b3
@ -502,10 +502,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||||||
|> render(StatusView, "index.json", %{activities: activities, for: user, as: :activity})
|
|> render(StatusView, "index.json", %{activities: activities, for: user, as: :activity})
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Pagination
|
|
||||||
def followers(conn, %{"id" => id}) do
|
def followers(conn, %{"id" => id}) do
|
||||||
with %User{} = user <- Repo.get(User, id),
|
with %User{} = user <- Repo.get(User, id),
|
||||||
{:ok, followers} <- User.get_followers(user) do
|
{:ok, followers} <- User.get_followers(user) do
|
||||||
|
followers = if(user.info.hide_network, do: [], else: followers)
|
||||||
render(conn, AccountView, "accounts.json", %{users: followers, as: :user})
|
render(conn, AccountView, "accounts.json", %{users: followers, as: :user})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -513,6 +513,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||||||
def following(conn, %{"id" => id}) do
|
def following(conn, %{"id" => id}) do
|
||||||
with %User{} = user <- Repo.get(User, id),
|
with %User{} = user <- Repo.get(User, id),
|
||||||
{:ok, followers} <- User.get_friends(user) do
|
{:ok, followers} <- User.get_friends(user) do
|
||||||
|
followers = if(user.info.hide_network, do: [], else: followers)
|
||||||
render(conn, AccountView, "accounts.json", %{users: followers, as: :user})
|
render(conn, AccountView, "accounts.json", %{users: followers, as: :user})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1002,6 +1002,18 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||||||
assert id == to_string(user.id)
|
assert id == to_string(user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "getting followers, hide_network", %{conn: conn} do
|
||||||
|
user = insert(:user)
|
||||||
|
other_user = insert(:user, %{info: %{hide_network: true}})
|
||||||
|
{:ok, user} = User.follow(user, other_user)
|
||||||
|
|
||||||
|
conn =
|
||||||
|
conn
|
||||||
|
|> get("/api/v1/accounts/#{other_user.id}/followers")
|
||||||
|
|
||||||
|
assert [] == json_response(conn, 200)
|
||||||
|
end
|
||||||
|
|
||||||
test "getting following", %{conn: conn} do
|
test "getting following", %{conn: conn} do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
other_user = insert(:user)
|
other_user = insert(:user)
|
||||||
@ -1015,6 +1027,18 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||||||
assert id == to_string(other_user.id)
|
assert id == to_string(other_user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "getting following, hide_network", %{conn: conn} do
|
||||||
|
user = insert(:user, %{info: %{hide_network: true}})
|
||||||
|
other_user = insert(:user)
|
||||||
|
{:ok, user} = User.follow(user, other_user)
|
||||||
|
|
||||||
|
conn =
|
||||||
|
conn
|
||||||
|
|> get("/api/v1/accounts/#{user.id}/following")
|
||||||
|
|
||||||
|
assert [] == json_response(conn, 200)
|
||||||
|
end
|
||||||
|
|
||||||
test "following / unfollowing a user", %{conn: conn} do
|
test "following / unfollowing a user", %{conn: conn} do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
other_user = insert(:user)
|
other_user = insert(:user)
|
||||||
|
Loading…
Reference in New Issue
Block a user