Merge branch 'revert-0a82a7e6' into 'develop'
Revert "Merge branch 'feature/split-hide-network' into 'develop'" See merge request pleroma/pleroma!758
This commit is contained in:
commit
09e1c8c05d
@ -30,8 +30,7 @@ defmodule Pleroma.User.Info do
|
|||||||
field(:topic, :string, default: nil)
|
field(:topic, :string, default: nil)
|
||||||
field(:hub, :string, default: nil)
|
field(:hub, :string, default: nil)
|
||||||
field(:salmon, :string, default: nil)
|
field(:salmon, :string, default: nil)
|
||||||
field(:hide_followers, :boolean, default: false)
|
field(:hide_network, :boolean, default: false)
|
||||||
field(:hide_followings, :boolean, default: false)
|
|
||||||
field(:pinned_activities, {:array, :string}, default: [])
|
field(:pinned_activities, {:array, :string}, default: [])
|
||||||
|
|
||||||
# Found in the wild
|
# Found in the wild
|
||||||
@ -144,8 +143,7 @@ def profile_update(info, params) do
|
|||||||
:no_rich_text,
|
:no_rich_text,
|
||||||
:default_scope,
|
:default_scope,
|
||||||
:banner,
|
:banner,
|
||||||
:hide_followings,
|
:hide_network,
|
||||||
:hide_followers,
|
|
||||||
:background
|
:background
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
@ -86,7 +86,7 @@ def render("following.json", %{user: user, page: page}) do
|
|||||||
query = from(user in query, select: [:ap_id])
|
query = from(user in query, select: [:ap_id])
|
||||||
following = Repo.all(query)
|
following = Repo.all(query)
|
||||||
|
|
||||||
collection(following, "#{user.ap_id}/following", page, !user.info.hide_followings)
|
collection(following, "#{user.ap_id}/following", page, !user.info.hide_network)
|
||||||
|> Map.merge(Utils.make_json_ld_header())
|
|> Map.merge(Utils.make_json_ld_header())
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ def render("following.json", %{user: user}) do
|
|||||||
"id" => "#{user.ap_id}/following",
|
"id" => "#{user.ap_id}/following",
|
||||||
"type" => "OrderedCollection",
|
"type" => "OrderedCollection",
|
||||||
"totalItems" => length(following),
|
"totalItems" => length(following),
|
||||||
"first" => collection(following, "#{user.ap_id}/following", 1, !user.info.hide_followings)
|
"first" => collection(following, "#{user.ap_id}/following", 1, !user.info.hide_network)
|
||||||
}
|
}
|
||||||
|> Map.merge(Utils.make_json_ld_header())
|
|> Map.merge(Utils.make_json_ld_header())
|
||||||
end
|
end
|
||||||
@ -109,7 +109,7 @@ def render("followers.json", %{user: user, page: page}) do
|
|||||||
query = from(user in query, select: [:ap_id])
|
query = from(user in query, select: [:ap_id])
|
||||||
followers = Repo.all(query)
|
followers = Repo.all(query)
|
||||||
|
|
||||||
collection(followers, "#{user.ap_id}/followers", page, !user.info.hide_followers)
|
collection(followers, "#{user.ap_id}/followers", page, !user.info.hide_network)
|
||||||
|> Map.merge(Utils.make_json_ld_header())
|
|> Map.merge(Utils.make_json_ld_header())
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ def render("followers.json", %{user: user}) do
|
|||||||
"id" => "#{user.ap_id}/followers",
|
"id" => "#{user.ap_id}/followers",
|
||||||
"type" => "OrderedCollection",
|
"type" => "OrderedCollection",
|
||||||
"totalItems" => length(followers),
|
"totalItems" => length(followers),
|
||||||
"first" => collection(followers, "#{user.ap_id}/followers", 1, !user.info.hide_followers)
|
"first" => collection(followers, "#{user.ap_id}/followers", 1, !user.info.hide_network)
|
||||||
}
|
}
|
||||||
|> Map.merge(Utils.make_json_ld_header())
|
|> Map.merge(Utils.make_json_ld_header())
|
||||||
end
|
end
|
||||||
|
@ -605,7 +605,7 @@ def followers(%{assigns: %{user: for_user}} = conn, %{"id" => id}) do
|
|||||||
followers =
|
followers =
|
||||||
cond do
|
cond do
|
||||||
for_user && user.id == for_user.id -> followers
|
for_user && user.id == for_user.id -> followers
|
||||||
user.info.hide_followers -> []
|
user.info.hide_network -> []
|
||||||
true -> followers
|
true -> followers
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -621,7 +621,7 @@ def following(%{assigns: %{user: for_user}} = conn, %{"id" => id}) do
|
|||||||
followers =
|
followers =
|
||||||
cond do
|
cond do
|
||||||
for_user && user.id == for_user.id -> followers
|
for_user && user.id == for_user.id -> followers
|
||||||
user.info.hide_followings -> []
|
user.info.hide_network -> []
|
||||||
true -> followers
|
true -> followers
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -503,7 +503,7 @@ def followers(%{assigns: %{user: for_user}} = conn, params) do
|
|||||||
followers =
|
followers =
|
||||||
cond do
|
cond do
|
||||||
for_user && user.id == for_user.id -> followers
|
for_user && user.id == for_user.id -> followers
|
||||||
user.info.hide_followers -> []
|
user.info.hide_network -> []
|
||||||
true -> followers
|
true -> followers
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -523,7 +523,7 @@ def friends(%{assigns: %{user: for_user}} = conn, params) do
|
|||||||
friends =
|
friends =
|
||||||
cond do
|
cond do
|
||||||
for_user && user.id == for_user.id -> friends
|
for_user && user.id == for_user.id -> friends
|
||||||
user.info.hide_followings -> []
|
user.info.hide_network -> []
|
||||||
true -> friends
|
true -> friends
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -618,7 +618,7 @@ def raw_empty_array(conn, _params) do
|
|||||||
|
|
||||||
defp build_info_cng(user, params) do
|
defp build_info_cng(user, params) do
|
||||||
info_params =
|
info_params =
|
||||||
["no_rich_text", "locked", "hide_followers", "hide_followings"]
|
["no_rich_text", "locked", "hide_network"]
|
||||||
|> Enum.reduce(%{}, fn key, res ->
|
|> Enum.reduce(%{}, fn key, res ->
|
||||||
if value = params[key] do
|
if value = params[key] do
|
||||||
Map.put(res, key, value == "true")
|
Map.put(res, key, value == "true")
|
||||||
|
@ -108,8 +108,7 @@ defp do_render("user.json", %{user: user = %User{}} = assigns) do
|
|||||||
"locked" => user.info.locked,
|
"locked" => user.info.locked,
|
||||||
"default_scope" => user.info.default_scope,
|
"default_scope" => user.info.default_scope,
|
||||||
"no_rich_text" => user.info.no_rich_text,
|
"no_rich_text" => user.info.no_rich_text,
|
||||||
"hide_followers" => user.info.hide_followers,
|
"hide_network" => user.info.hide_network,
|
||||||
"hide_followings" => user.info.hide_followings,
|
|
||||||
"fields" => fields,
|
"fields" => fields,
|
||||||
|
|
||||||
# Pleroma extension
|
# Pleroma extension
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
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
|
|
@ -386,9 +386,9 @@ test "it returns the followers in a collection", %{conn: conn} do
|
|||||||
assert result["first"]["orderedItems"] == [user.ap_id]
|
assert result["first"]["orderedItems"] == [user.ap_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it returns returns empty if the user has 'hide_followers' set", %{conn: conn} do
|
test "it returns returns empty if the user has 'hide_network' set", %{conn: conn} do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
user_two = insert(:user, %{info: %{hide_followers: true}})
|
user_two = insert(:user, %{info: %{hide_network: true}})
|
||||||
User.follow(user, user_two)
|
User.follow(user, user_two)
|
||||||
|
|
||||||
result =
|
result =
|
||||||
@ -441,8 +441,8 @@ test "it returns the following in a collection", %{conn: conn} do
|
|||||||
assert result["first"]["orderedItems"] == [user_two.ap_id]
|
assert result["first"]["orderedItems"] == [user_two.ap_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it returns returns empty if the user has 'hide_followings' set", %{conn: conn} do
|
test "it returns returns empty if the user has 'hide_network' set", %{conn: conn} do
|
||||||
user = insert(:user, %{info: %{hide_followings: true}})
|
user = insert(:user, %{info: %{hide_network: true}})
|
||||||
user_two = insert(:user)
|
user_two = insert(:user)
|
||||||
User.follow(user, user_two)
|
User.follow(user, user_two)
|
||||||
|
|
||||||
|
@ -1099,9 +1099,9 @@ test "getting followers", %{conn: conn} do
|
|||||||
assert id == to_string(user.id)
|
assert id == to_string(user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "getting followers, hide_followers", %{conn: conn} do
|
test "getting followers, hide_network", %{conn: conn} do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
other_user = insert(:user, %{info: %{hide_followers: true}})
|
other_user = insert(:user, %{info: %{hide_network: true}})
|
||||||
{:ok, _user} = User.follow(user, other_user)
|
{:ok, _user} = User.follow(user, other_user)
|
||||||
|
|
||||||
conn =
|
conn =
|
||||||
@ -1111,9 +1111,9 @@ test "getting followers, hide_followers", %{conn: conn} do
|
|||||||
assert [] == json_response(conn, 200)
|
assert [] == json_response(conn, 200)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "getting followers, hide_followers, same user requesting", %{conn: conn} do
|
test "getting followers, hide_network, same user requesting", %{conn: conn} do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
other_user = insert(:user, %{info: %{hide_followers: true}})
|
other_user = insert(:user, %{info: %{hide_network: true}})
|
||||||
{:ok, _user} = User.follow(user, other_user)
|
{:ok, _user} = User.follow(user, other_user)
|
||||||
|
|
||||||
conn =
|
conn =
|
||||||
@ -1137,8 +1137,8 @@ test "getting following", %{conn: conn} do
|
|||||||
assert id == to_string(other_user.id)
|
assert id == to_string(other_user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "getting following, hide_followings", %{conn: conn} do
|
test "getting following, hide_network", %{conn: conn} do
|
||||||
user = insert(:user, %{info: %{hide_followings: true}})
|
user = insert(:user, %{info: %{hide_network: true}})
|
||||||
other_user = insert(:user)
|
other_user = insert(:user)
|
||||||
{:ok, user} = User.follow(user, other_user)
|
{:ok, user} = User.follow(user, other_user)
|
||||||
|
|
||||||
@ -1149,8 +1149,8 @@ test "getting following, hide_followings", %{conn: conn} do
|
|||||||
assert [] == json_response(conn, 200)
|
assert [] == json_response(conn, 200)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "getting following, hide_followings, same user requesting", %{conn: conn} do
|
test "getting following, hide_network, same user requesting", %{conn: conn} do
|
||||||
user = insert(:user, %{info: %{hide_followings: true}})
|
user = insert(:user, %{info: %{hide_network: true}})
|
||||||
other_user = insert(:user)
|
other_user = insert(:user)
|
||||||
{:ok, user} = User.follow(user, other_user)
|
{:ok, user} = User.follow(user, other_user)
|
||||||
|
|
||||||
|
@ -1132,8 +1132,8 @@ test "it returns a given user's followers with user_id", %{conn: conn} do
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it returns empty when hide_followers is set to true", %{conn: conn} do
|
test "it returns empty for a hidden network", %{conn: conn} do
|
||||||
user = insert(:user, %{info: %{hide_followers: true}})
|
user = insert(:user, %{info: %{hide_network: true}})
|
||||||
follower_one = insert(:user)
|
follower_one = insert(:user)
|
||||||
follower_two = insert(:user)
|
follower_two = insert(:user)
|
||||||
not_follower = insert(:user)
|
not_follower = insert(:user)
|
||||||
@ -1150,11 +1150,10 @@ test "it returns empty when hide_followers is set to true", %{conn: conn} do
|
|||||||
assert [] == response
|
assert [] == response
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it returns the followers when hide_followers is set to true if requested by the user themselves",
|
test "it returns the followers for a hidden network if requested by the user themselves", %{
|
||||||
%{
|
|
||||||
conn: conn
|
conn: conn
|
||||||
} do
|
} do
|
||||||
user = insert(:user, %{info: %{hide_followers: true}})
|
user = insert(:user, %{info: %{hide_network: true}})
|
||||||
follower_one = insert(:user)
|
follower_one = insert(:user)
|
||||||
follower_two = insert(:user)
|
follower_two = insert(:user)
|
||||||
_not_follower = insert(:user)
|
_not_follower = insert(:user)
|
||||||
@ -1257,8 +1256,8 @@ test "it returns a given user's friends with user_id", %{conn: conn} do
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it returns empty when hide_followings is set to true", %{conn: conn} do
|
test "it returns empty for a hidden network", %{conn: conn} do
|
||||||
user = insert(:user, %{info: %{hide_followings: true}})
|
user = insert(:user, %{info: %{hide_network: true}})
|
||||||
followed_one = insert(:user)
|
followed_one = insert(:user)
|
||||||
followed_two = insert(:user)
|
followed_two = insert(:user)
|
||||||
not_followed = insert(:user)
|
not_followed = insert(:user)
|
||||||
@ -1274,11 +1273,10 @@ test "it returns empty when hide_followings is set to true", %{conn: conn} do
|
|||||||
assert [] == json_response(conn, 200)
|
assert [] == json_response(conn, 200)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it returns friends when hide_followings is set to true if the user themselves request it",
|
test "it returns friends for a hidden network if the user themselves request it", %{
|
||||||
%{
|
|
||||||
conn: conn
|
conn: conn
|
||||||
} do
|
} do
|
||||||
user = insert(:user, %{info: %{hide_followings: true}})
|
user = insert(:user, %{info: %{hide_network: true}})
|
||||||
followed_one = insert(:user)
|
followed_one = insert(:user)
|
||||||
followed_two = insert(:user)
|
followed_two = insert(:user)
|
||||||
_not_followed = insert(:user)
|
_not_followed = insert(:user)
|
||||||
@ -1366,51 +1364,27 @@ test "it updates a user's profile", %{conn: conn} do
|
|||||||
assert json_response(conn, 200) == UserView.render("user.json", %{user: user, for: user})
|
assert json_response(conn, 200) == UserView.render("user.json", %{user: user, for: user})
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it sets and un-sets hide_followings", %{conn: conn} do
|
test "it sets and un-sets hide_network", %{conn: conn} do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> assign(:user, user)
|
|> assign(:user, user)
|
||||||
|> post("/api/account/update_profile.json", %{
|
|> post("/api/account/update_profile.json", %{
|
||||||
"hide_followings" => "true"
|
"hide_network" => "true"
|
||||||
})
|
})
|
||||||
|
|
||||||
user = Repo.get!(User, user.id)
|
user = Repo.get!(User, user.id)
|
||||||
assert user.info.hide_followings == true
|
assert user.info.hide_network == true
|
||||||
|
|
||||||
conn =
|
conn =
|
||||||
conn
|
conn
|
||||||
|> assign(:user, user)
|
|> assign(:user, user)
|
||||||
|> post("/api/account/update_profile.json", %{
|
|> post("/api/account/update_profile.json", %{
|
||||||
"hide_followings" => "false"
|
"hide_network" => "false"
|
||||||
})
|
})
|
||||||
|
|
||||||
user = Repo.get!(User, user.id)
|
user = Repo.get!(User, user.id)
|
||||||
assert user.info.hide_followings == false
|
assert user.info.hide_network == 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})
|
assert json_response(conn, 200) == UserView.render("user.json", %{user: user, for: user})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -100,8 +100,7 @@ test "A user" do
|
|||||||
"locked" => false,
|
"locked" => false,
|
||||||
"default_scope" => "public",
|
"default_scope" => "public",
|
||||||
"no_rich_text" => false,
|
"no_rich_text" => false,
|
||||||
"hide_followings" => false,
|
"hide_network" => false,
|
||||||
"hide_followers" => false,
|
|
||||||
"fields" => [],
|
"fields" => [],
|
||||||
"pleroma" => %{
|
"pleroma" => %{
|
||||||
"confirmation_pending" => false,
|
"confirmation_pending" => false,
|
||||||
@ -148,8 +147,7 @@ test "A user for a given other follower", %{user: user} do
|
|||||||
"locked" => false,
|
"locked" => false,
|
||||||
"default_scope" => "public",
|
"default_scope" => "public",
|
||||||
"no_rich_text" => false,
|
"no_rich_text" => false,
|
||||||
"hide_followings" => false,
|
"hide_network" => false,
|
||||||
"hide_followers" => false,
|
|
||||||
"fields" => [],
|
"fields" => [],
|
||||||
"pleroma" => %{
|
"pleroma" => %{
|
||||||
"confirmation_pending" => false,
|
"confirmation_pending" => false,
|
||||||
@ -197,8 +195,7 @@ test "A user that follows you", %{user: user} do
|
|||||||
"locked" => false,
|
"locked" => false,
|
||||||
"default_scope" => "public",
|
"default_scope" => "public",
|
||||||
"no_rich_text" => false,
|
"no_rich_text" => false,
|
||||||
"hide_followings" => false,
|
"hide_network" => false,
|
||||||
"hide_followers" => false,
|
|
||||||
"fields" => [],
|
"fields" => [],
|
||||||
"pleroma" => %{
|
"pleroma" => %{
|
||||||
"confirmation_pending" => false,
|
"confirmation_pending" => false,
|
||||||
@ -260,8 +257,7 @@ test "A blocked user for the blocker" do
|
|||||||
"locked" => false,
|
"locked" => false,
|
||||||
"default_scope" => "public",
|
"default_scope" => "public",
|
||||||
"no_rich_text" => false,
|
"no_rich_text" => false,
|
||||||
"hide_followings" => false,
|
"hide_network" => false,
|
||||||
"hide_followers" => false,
|
|
||||||
"fields" => [],
|
"fields" => [],
|
||||||
"pleroma" => %{
|
"pleroma" => %{
|
||||||
"confirmation_pending" => false,
|
"confirmation_pending" => false,
|
||||||
|
Loading…
Reference in New Issue
Block a user