TwitterAPI: Add network hiding.

This commit is contained in:
lain 2018-12-05 19:22:40 +01:00
parent 8c9a4e8b40
commit 839526a913
3 changed files with 27 additions and 2 deletions

View file

@ -135,7 +135,8 @@ def profile_update(info, params) do
:locked, :locked,
:no_rich_text, :no_rich_text,
:default_scope, :default_scope,
:banner :banner,
:hide_network
]) ])
end end

View file

@ -431,7 +431,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"] ["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")

View file

@ -1024,6 +1024,30 @@ 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_network", %{conn: conn} do
user = insert(:user)
conn
|> assign(:user, user)
|> post("/api/account/update_profile.json", %{
"hide_network" => "true"
})
user = Repo.get!(User, user.id)
assert user.info.hide_network == true
conn =
conn
|> assign(:user, user)
|> post("/api/account/update_profile.json", %{
"hide_network" => "false"
})
user = Repo.get!(User, user.id)
assert user.info.hide_network == false
assert json_response(conn, 200) == UserView.render("user.json", %{user: user, for: user})
end
test "it locks an account", %{conn: conn} do test "it locks an account", %{conn: conn} do
user = insert(:user) user = insert(:user)