v2 Suggestions: return `is_suggested` through the API

This commit is contained in:
Alex Gleason 2021-11-26 23:10:01 -06:00
parent 8dc1d2201a
commit 6519f59d91
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
4 changed files with 9 additions and 2 deletions

View File

@ -80,6 +80,7 @@ def render("show.json", %{user: user}) do
"tags" => user.tags || [],
"is_confirmed" => user.is_confirmed,
"is_approved" => user.is_approved,
"is_suggested" => user.is_suggested,
"url" => user.uri || user.ap_id,
"registration_reason" => user.registration_reason,
"actor_type" => user.actor_type,

View File

@ -269,6 +269,7 @@ defp do_render("show.json", %{user: user} = opts) do
ap_id: user.ap_id,
also_known_as: user.also_known_as,
is_confirmed: user.is_confirmed,
is_suggested: user.is_suggested,
tags: user.tags,
hide_followers_count: user.hide_followers_count,
hide_follows_count: user.hide_follows_count,

View File

@ -877,7 +877,7 @@ test "PATCH /api/pleroma/admin/users/suggest", %{admin: admin, conn: conn} do
user1 = insert(:user, is_suggested: false)
user2 = insert(:user, is_suggested: false)
_response =
response =
conn
|> put_req_header("content-type", "application/json")
|> patch(
@ -886,6 +886,7 @@ test "PATCH /api/pleroma/admin/users/suggest", %{admin: admin, conn: conn} do
)
|> json_response_and_validate_schema(200)
assert Enum.map(response["users"], & &1["is_suggested"]) == [true, true]
[user1, user2] = Repo.reload!([user1, user2])
assert user1.is_suggested
@ -901,7 +902,7 @@ test "PATCH /api/pleroma/admin/users/unsuggest", %{admin: admin, conn: conn} do
user1 = insert(:user, is_suggested: true)
user2 = insert(:user, is_suggested: true)
_response =
response =
conn
|> put_req_header("content-type", "application/json")
|> patch(
@ -910,6 +911,7 @@ test "PATCH /api/pleroma/admin/users/unsuggest", %{admin: admin, conn: conn} do
)
|> json_response_and_validate_schema(200)
assert Enum.map(response["users"], & &1["is_suggested"]) == [false, false]
[user1, user2] = Repo.reload!([user1, user2])
refute user1.is_suggested
@ -954,6 +956,7 @@ defp user_response(user, attrs \\ %{}) do
"display_name" => HTML.strip_tags(user.name || user.nickname),
"is_confirmed" => true,
"is_approved" => true,
"is_suggested" => false,
"url" => user.ap_id,
"registration_reason" => nil,
"actor_type" => "Person",

View File

@ -83,6 +83,7 @@ test "Represent a user account" do
tags: [],
is_admin: false,
is_moderator: false,
is_suggested: false,
hide_favorites: true,
hide_followers: false,
hide_follows: false,
@ -183,6 +184,7 @@ test "Represent a Service(bot) account" do
tags: [],
is_admin: false,
is_moderator: false,
is_suggested: false,
hide_favorites: true,
hide_followers: false,
hide_follows: false,