update api to set skip_thread_containment
This commit is contained in:
parent
080e1aa70e
commit
f13d6c7f78
|
@ -80,6 +80,7 @@ Additional parameters can be added to the JSON body/Form data:
|
||||||
- `hide_favorites` - if true, user's favorites timeline will be hidden
|
- `hide_favorites` - if true, user's favorites timeline will be hidden
|
||||||
- `show_role` - if true, user's role (e.g admin, moderator) will be exposed to anyone in the API
|
- `show_role` - if true, user's role (e.g admin, moderator) will be exposed to anyone in the API
|
||||||
- `default_scope` - the scope returned under `privacy` key in Source subentity
|
- `default_scope` - the scope returned under `privacy` key in Source subentity
|
||||||
|
- `skip_thread_containment` - if true, skip filtering out broken threads
|
||||||
|
|
||||||
## Authentication
|
## Authentication
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,15 @@ def update_credentials(%{assigns: %{user: user}} = conn, params) do
|
||||||
|> Enum.dedup()
|
|> Enum.dedup()
|
||||||
|
|
||||||
info_params =
|
info_params =
|
||||||
[:no_rich_text, :locked, :hide_followers, :hide_follows, :hide_favorites, :show_role]
|
[
|
||||||
|
:no_rich_text,
|
||||||
|
:locked,
|
||||||
|
:hide_followers,
|
||||||
|
:hide_follows,
|
||||||
|
:hide_favorites,
|
||||||
|
:show_role,
|
||||||
|
:skip_thread_containment
|
||||||
|
]
|
||||||
|> Enum.reduce(%{}, fn key, acc ->
|
|> Enum.reduce(%{}, fn key, acc ->
|
||||||
add_if_present(acc, params, to_string(key), key, fn value ->
|
add_if_present(acc, params, to_string(key), key, fn value ->
|
||||||
{:ok, ControllerHelper.truthy_param?(value)}
|
{:ok, ControllerHelper.truthy_param?(value)}
|
||||||
|
|
|
@ -124,7 +124,8 @@ defp do_render("account.json", %{user: user} = opts) do
|
||||||
hide_followers: user.info.hide_followers,
|
hide_followers: user.info.hide_followers,
|
||||||
hide_follows: user.info.hide_follows,
|
hide_follows: user.info.hide_follows,
|
||||||
hide_favorites: user.info.hide_favorites,
|
hide_favorites: user.info.hide_favorites,
|
||||||
relationship: relationship
|
relationship: relationship,
|
||||||
|
skip_thread_containment: user.info.skip_thread_containment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|> maybe_put_role(user, opts[:for])
|
|> maybe_put_role(user, opts[:for])
|
||||||
|
|
|
@ -632,7 +632,15 @@ 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_follows", "hide_favorites", "show_role"]
|
[
|
||||||
|
"no_rich_text",
|
||||||
|
"locked",
|
||||||
|
"hide_followers",
|
||||||
|
"hide_follows",
|
||||||
|
"hide_favorites",
|
||||||
|
"show_role",
|
||||||
|
"skip_thread_containment"
|
||||||
|
]
|
||||||
|> 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")
|
||||||
|
|
|
@ -118,7 +118,8 @@ defp do_render("user.json", %{user: user = %User{}} = assigns) do
|
||||||
"pleroma" =>
|
"pleroma" =>
|
||||||
%{
|
%{
|
||||||
"confirmation_pending" => user_info.confirmation_pending,
|
"confirmation_pending" => user_info.confirmation_pending,
|
||||||
"tags" => user.tags
|
"tags" => user.tags,
|
||||||
|
"skip_thread_containment" => user.info.skip_thread_containment
|
||||||
}
|
}
|
||||||
|> maybe_with_activation_status(user, for_user)
|
|> maybe_with_activation_status(user, for_user)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2378,6 +2378,19 @@ test "updates the user's hide_followers status", %{conn: conn} do
|
||||||
assert user["pleroma"]["hide_followers"] == true
|
assert user["pleroma"]["hide_followers"] == true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "updates the user's skip_thread_containment option", %{conn: conn} do
|
||||||
|
user = insert(:user)
|
||||||
|
|
||||||
|
response =
|
||||||
|
conn
|
||||||
|
|> assign(:user, user)
|
||||||
|
|> patch("/api/v1/accounts/update_credentials", %{skip_thread_containment: "true"})
|
||||||
|
|> json_response(200)
|
||||||
|
|
||||||
|
assert response["pleroma"]["skip_thread_containment"] == true
|
||||||
|
assert refresh_record(user).info.skip_thread_containment
|
||||||
|
end
|
||||||
|
|
||||||
test "updates the user's hide_follows status", %{conn: conn} do
|
test "updates the user's hide_follows status", %{conn: conn} do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
|
|
|
@ -1495,7 +1495,7 @@ test "it sets and un-sets hide_follows", %{conn: conn} do
|
||||||
"hide_follows" => "false"
|
"hide_follows" => "false"
|
||||||
})
|
})
|
||||||
|
|
||||||
user = Repo.get!(User, user.id)
|
user = refresh_record(user)
|
||||||
assert user.info.hide_follows == false
|
assert user.info.hide_follows == 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
|
||||||
|
@ -1548,6 +1548,29 @@ test "it sets and un-sets show_role", %{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 skip_thread_containment", %{conn: conn} do
|
||||||
|
user = insert(:user)
|
||||||
|
|
||||||
|
response =
|
||||||
|
conn
|
||||||
|
|> assign(:user, user)
|
||||||
|
|> post("/api/account/update_profile.json", %{"skip_thread_containment" => "true"})
|
||||||
|
|> json_response(200)
|
||||||
|
|
||||||
|
assert response["pleroma"]["skip_thread_containment"] == true
|
||||||
|
user = refresh_record(user)
|
||||||
|
assert user.info.skip_thread_containment
|
||||||
|
|
||||||
|
response =
|
||||||
|
conn
|
||||||
|
|> assign(:user, user)
|
||||||
|
|> post("/api/account/update_profile.json", %{"skip_thread_containment" => "false"})
|
||||||
|
|> json_response(200)
|
||||||
|
|
||||||
|
assert response["pleroma"]["skip_thread_containment"] == false
|
||||||
|
refute refresh_record(user).info.skip_thread_containment
|
||||||
|
end
|
||||||
|
|
||||||
test "it locks an account", %{conn: conn} do
|
test "it locks an account", %{conn: conn} do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue