field(:topic, :string, default: nil)
field(:hub, :string, default: nil)
field(:salmon, :string, default: nil)
- field(:hide_network, :boolean, default: false)
+ field(:hide_followers, :boolean, default: false)
+ field(:hide_followings, :boolean, default: false)
field(:pinned_activities, {:array, :string}, default: [])
# Found in the wild
:no_rich_text,
:default_scope,
:banner,
- :hide_network,
+ :hide_followings,
+ :hide_followers,
:background
])
end
query = from(user in query, select: [:ap_id])
following = Repo.all(query)
- collection(following, "#{user.ap_id}/following", page, !user.info.hide_network)
+ collection(following, "#{user.ap_id}/following", page, !user.info.hide_followings)
|> Map.merge(Utils.make_json_ld_header())
end
"id" => "#{user.ap_id}/following",
"type" => "OrderedCollection",
"totalItems" => length(following),
- "first" => collection(following, "#{user.ap_id}/following", 1, !user.info.hide_network)
+ "first" => collection(following, "#{user.ap_id}/following", 1, !user.info.hide_followings)
}
|> Map.merge(Utils.make_json_ld_header())
end
query = from(user in query, select: [:ap_id])
followers = Repo.all(query)
- collection(followers, "#{user.ap_id}/followers", page, !user.info.hide_network)
+ collection(followers, "#{user.ap_id}/followers", page, !user.info.hide_followers)
|> Map.merge(Utils.make_json_ld_header())
end
"id" => "#{user.ap_id}/followers",
"type" => "OrderedCollection",
"totalItems" => length(followers),
- "first" => collection(followers, "#{user.ap_id}/followers", 1, !user.info.hide_network)
+ "first" => collection(followers, "#{user.ap_id}/followers", 1, !user.info.hide_followers)
}
|> Map.merge(Utils.make_json_ld_header())
end
followers =
cond do
for_user && user.id == for_user.id -> followers
- user.info.hide_network -> []
+ user.info.hide_followers -> []
true -> followers
end
followers =
cond do
for_user && user.id == for_user.id -> followers
- user.info.hide_network -> []
+ user.info.hide_followings -> []
true -> followers
end
followers =
cond do
for_user && user.id == for_user.id -> followers
- user.info.hide_network -> []
+ user.info.hide_followers -> []
true -> followers
end
friends =
cond do
for_user && user.id == for_user.id -> friends
- user.info.hide_network -> []
+ user.info.hide_followings -> []
true -> friends
end
defp build_info_cng(user, params) do
info_params =
- ["no_rich_text", "locked", "hide_network"]
+ ["no_rich_text", "locked", "hide_followers", "hide_followings"]
|> Enum.reduce(%{}, fn key, res ->
if value = params[key] do
Map.put(res, key, value == "true")
"locked" => user.info.locked,
"default_scope" => user.info.default_scope,
"no_rich_text" => user.info.no_rich_text,
- "hide_network" => user.info.hide_network,
+ "hide_followers" => user.info.hide_followers,
+ "hide_followings" => user.info.hide_followings,
"fields" => fields,
# Pleroma extension
--- /dev/null
+defmodule Pleroma.Repo.Migrations.SplitHideNetwork do
+ use Ecto.Migration
+
+ def up do
+ execute("UPDATE users SET info = jsonb_set(jsonb_set(info, '{hide_followers}'::text[], info->'hide_network'), '{hide_followings}'::text[], info->'hide_network')")
+ end
+
+ def down do
+ end
+end
assert result["first"]["orderedItems"] == [user.ap_id]
end
- test "it returns returns empty if the user has 'hide_network' set", %{conn: conn} do
+ test "it returns returns empty if the user has 'hide_followers' set", %{conn: conn} do
user = insert(:user)
- user_two = insert(:user, %{info: %{hide_network: true}})
+ user_two = insert(:user, %{info: %{hide_followers: true}})
User.follow(user, user_two)
result =
assert result["first"]["orderedItems"] == [user_two.ap_id]
end
- test "it returns returns empty if the user has 'hide_network' set", %{conn: conn} do
- user = insert(:user, %{info: %{hide_network: true}})
+ test "it returns returns empty if the user has 'hide_followings' set", %{conn: conn} do
+ user = insert(:user, %{info: %{hide_followings: true}})
user_two = insert(:user)
User.follow(user, user_two)
assert id == to_string(user.id)
end
- test "getting followers, hide_network", %{conn: conn} do
+ test "getting followers, hide_followers", %{conn: conn} do
user = insert(:user)
- other_user = insert(:user, %{info: %{hide_network: true}})
+ other_user = insert(:user, %{info: %{hide_followers: true}})
{:ok, _user} = User.follow(user, other_user)
conn =
assert [] == json_response(conn, 200)
end
- test "getting followers, hide_network, same user requesting", %{conn: conn} do
+ test "getting followers, hide_followers, same user requesting", %{conn: conn} do
user = insert(:user)
- other_user = insert(:user, %{info: %{hide_network: true}})
+ other_user = insert(:user, %{info: %{hide_followers: true}})
{:ok, _user} = User.follow(user, other_user)
conn =
assert id == to_string(other_user.id)
end
- test "getting following, hide_network", %{conn: conn} do
- user = insert(:user, %{info: %{hide_network: true}})
+ test "getting following, hide_followings", %{conn: conn} do
+ user = insert(:user, %{info: %{hide_followings: true}})
other_user = insert(:user)
{:ok, user} = User.follow(user, other_user)
assert [] == json_response(conn, 200)
end
- test "getting following, hide_network, same user requesting", %{conn: conn} do
- user = insert(:user, %{info: %{hide_network: true}})
+ test "getting following, hide_followings, same user requesting", %{conn: conn} do
+ user = insert(:user, %{info: %{hide_followings: true}})
other_user = insert(:user)
{:ok, user} = User.follow(user, other_user)
)
end
- test "it returns empty for a hidden network", %{conn: conn} do
- user = insert(:user, %{info: %{hide_network: true}})
+ test "it returns empty when hide_followers is set to true", %{conn: conn} do
+ user = insert(:user, %{info: %{hide_followers: true}})
follower_one = insert(:user)
follower_two = insert(:user)
not_follower = insert(:user)
assert [] == response
end
- test "it returns the followers for a hidden network if requested by the user themselves", %{
+ test "it returns the followers when hide_followers is set to true if requested by the user themselves", %{
conn: conn
} do
- user = insert(:user, %{info: %{hide_network: true}})
+ user = insert(:user, %{info: %{hide_followers: true}})
follower_one = insert(:user)
follower_two = insert(:user)
_not_follower = insert(:user)
)
end
- test "it returns empty for a hidden network", %{conn: conn} do
- user = insert(:user, %{info: %{hide_network: true}})
+ test "it returns empty when hide_followings is set to true", %{conn: conn} do
+ user = insert(:user, %{info: %{hide_followings: true}})
followed_one = insert(:user)
followed_two = insert(:user)
not_followed = insert(:user)
assert [] == json_response(conn, 200)
end
- test "it returns friends for a hidden network if the user themselves request it", %{
+ test "it returns friends when hide_followings is set to true if the user themselves request it", %{
conn: conn
} do
- user = insert(:user, %{info: %{hide_network: true}})
+ user = insert(:user, %{info: %{hide_followings: true}})
followed_one = insert(:user)
followed_two = insert(:user)
_not_followed = insert(:user)
assert json_response(conn, 200) == UserView.render("user.json", %{user: user, for: user})
end
- test "it sets and un-sets hide_network", %{conn: conn} do
+ test "it sets and un-sets hide_followings", %{conn: conn} do
user = insert(:user)
conn
|> assign(:user, user)
|> post("/api/account/update_profile.json", %{
- "hide_network" => "true"
+ "hide_followings" => "true"
})
user = Repo.get!(User, user.id)
- assert user.info.hide_network == true
+ assert user.info.hide_followings == true
conn =
conn
|> assign(:user, user)
|> post("/api/account/update_profile.json", %{
- "hide_network" => "false"
+ "hide_followings" => "false"
})
user = Repo.get!(User, user.id)
- assert user.info.hide_network == false
+ assert user.info.hide_followings == false
+ assert json_response(conn, 200) == UserView.render("user.json", %{user: user, for: user})
+ end
+
+ test "it sets and un-sets hide_followers", %{conn: conn} do
+ user = insert(:user)
+
+ conn
+ |> assign(:user, user)
+ |> post("/api/account/update_profile.json", %{
+ "hide_followers" => "true"
+ })
+
+ user = Repo.get!(User, user.id)
+ assert user.info.hide_followers == true
+
+ conn =
+ conn
+ |> assign(:user, user)
+ |> post("/api/account/update_profile.json", %{
+ "hide_followers" => "false"
+ })
+
+ user = Repo.get!(User, user.id)
+ assert user.info.hide_followers == false
assert json_response(conn, 200) == UserView.render("user.json", %{user: user, for: user})
end
"locked" => false,
"default_scope" => "public",
"no_rich_text" => false,
- "hide_network" => false,
+ "hide_followings" => false,
+ "hide_followers" => false,
"fields" => [],
"pleroma" => %{
"confirmation_pending" => false,
"locked" => false,
"default_scope" => "public",
"no_rich_text" => false,
- "hide_network" => false,
+ "hide_followings" => false,
+ "hide_followers" => false,
"fields" => [],
"pleroma" => %{
"confirmation_pending" => false,
"locked" => false,
"default_scope" => "public",
"no_rich_text" => false,
- "hide_network" => false,
+ "hide_followings" => false,
+ "hide_followers" => false,
"fields" => [],
"pleroma" => %{
"confirmation_pending" => false,
"locked" => false,
"default_scope" => "public",
"no_rich_text" => false,
- "hide_network" => false,
+ "hide_followings" => false,
+ "hide_followers" => false,
"fields" => [],
"pleroma" => %{
"confirmation_pending" => false,