forked from YokaiRick/akkoma
v2 Suggestions: return is_suggested
through the API
This commit is contained in:
parent
8dc1d2201a
commit
6519f59d91
4 changed files with 9 additions and 2 deletions
|
@ -80,6 +80,7 @@ def render("show.json", %{user: user}) do
|
||||||
"tags" => user.tags || [],
|
"tags" => user.tags || [],
|
||||||
"is_confirmed" => user.is_confirmed,
|
"is_confirmed" => user.is_confirmed,
|
||||||
"is_approved" => user.is_approved,
|
"is_approved" => user.is_approved,
|
||||||
|
"is_suggested" => user.is_suggested,
|
||||||
"url" => user.uri || user.ap_id,
|
"url" => user.uri || user.ap_id,
|
||||||
"registration_reason" => user.registration_reason,
|
"registration_reason" => user.registration_reason,
|
||||||
"actor_type" => user.actor_type,
|
"actor_type" => user.actor_type,
|
||||||
|
|
|
@ -269,6 +269,7 @@ defp do_render("show.json", %{user: user} = opts) do
|
||||||
ap_id: user.ap_id,
|
ap_id: user.ap_id,
|
||||||
also_known_as: user.also_known_as,
|
also_known_as: user.also_known_as,
|
||||||
is_confirmed: user.is_confirmed,
|
is_confirmed: user.is_confirmed,
|
||||||
|
is_suggested: user.is_suggested,
|
||||||
tags: user.tags,
|
tags: user.tags,
|
||||||
hide_followers_count: user.hide_followers_count,
|
hide_followers_count: user.hide_followers_count,
|
||||||
hide_follows_count: user.hide_follows_count,
|
hide_follows_count: user.hide_follows_count,
|
||||||
|
|
|
@ -877,7 +877,7 @@ test "PATCH /api/pleroma/admin/users/suggest", %{admin: admin, conn: conn} do
|
||||||
user1 = insert(:user, is_suggested: false)
|
user1 = insert(:user, is_suggested: false)
|
||||||
user2 = insert(:user, is_suggested: false)
|
user2 = insert(:user, is_suggested: false)
|
||||||
|
|
||||||
_response =
|
response =
|
||||||
conn
|
conn
|
||||||
|> put_req_header("content-type", "application/json")
|
|> put_req_header("content-type", "application/json")
|
||||||
|> patch(
|
|> patch(
|
||||||
|
@ -886,6 +886,7 @@ test "PATCH /api/pleroma/admin/users/suggest", %{admin: admin, conn: conn} do
|
||||||
)
|
)
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
|
assert Enum.map(response["users"], & &1["is_suggested"]) == [true, true]
|
||||||
[user1, user2] = Repo.reload!([user1, user2])
|
[user1, user2] = Repo.reload!([user1, user2])
|
||||||
|
|
||||||
assert user1.is_suggested
|
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)
|
user1 = insert(:user, is_suggested: true)
|
||||||
user2 = insert(:user, is_suggested: true)
|
user2 = insert(:user, is_suggested: true)
|
||||||
|
|
||||||
_response =
|
response =
|
||||||
conn
|
conn
|
||||||
|> put_req_header("content-type", "application/json")
|
|> put_req_header("content-type", "application/json")
|
||||||
|> patch(
|
|> patch(
|
||||||
|
@ -910,6 +911,7 @@ test "PATCH /api/pleroma/admin/users/unsuggest", %{admin: admin, conn: conn} do
|
||||||
)
|
)
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
|
assert Enum.map(response["users"], & &1["is_suggested"]) == [false, false]
|
||||||
[user1, user2] = Repo.reload!([user1, user2])
|
[user1, user2] = Repo.reload!([user1, user2])
|
||||||
|
|
||||||
refute user1.is_suggested
|
refute user1.is_suggested
|
||||||
|
@ -954,6 +956,7 @@ defp user_response(user, attrs \\ %{}) do
|
||||||
"display_name" => HTML.strip_tags(user.name || user.nickname),
|
"display_name" => HTML.strip_tags(user.name || user.nickname),
|
||||||
"is_confirmed" => true,
|
"is_confirmed" => true,
|
||||||
"is_approved" => true,
|
"is_approved" => true,
|
||||||
|
"is_suggested" => false,
|
||||||
"url" => user.ap_id,
|
"url" => user.ap_id,
|
||||||
"registration_reason" => nil,
|
"registration_reason" => nil,
|
||||||
"actor_type" => "Person",
|
"actor_type" => "Person",
|
||||||
|
|
|
@ -83,6 +83,7 @@ test "Represent a user account" do
|
||||||
tags: [],
|
tags: [],
|
||||||
is_admin: false,
|
is_admin: false,
|
||||||
is_moderator: false,
|
is_moderator: false,
|
||||||
|
is_suggested: false,
|
||||||
hide_favorites: true,
|
hide_favorites: true,
|
||||||
hide_followers: false,
|
hide_followers: false,
|
||||||
hide_follows: false,
|
hide_follows: false,
|
||||||
|
@ -183,6 +184,7 @@ test "Represent a Service(bot) account" do
|
||||||
tags: [],
|
tags: [],
|
||||||
is_admin: false,
|
is_admin: false,
|
||||||
is_moderator: false,
|
is_moderator: false,
|
||||||
|
is_suggested: false,
|
||||||
hide_favorites: true,
|
hide_favorites: true,
|
||||||
hide_followers: false,
|
hide_followers: false,
|
||||||
hide_follows: false,
|
hide_follows: false,
|
||||||
|
|
Loading…
Reference in a new issue