v2 Suggestions: return `is_suggested` through the API
authorAlex Gleason <alex@alexgleason.me>
Sat, 27 Nov 2021 05:10:01 +0000 (23:10 -0600)
committerAlex Gleason <alex@alexgleason.me>
Sat, 27 Nov 2021 05:10:01 +0000 (23:10 -0600)
lib/pleroma/web/admin_api/views/account_view.ex
lib/pleroma/web/mastodon_api/views/account_view.ex
test/pleroma/web/admin_api/controllers/user_controller_test.exs
test/pleroma/web/mastodon_api/views/account_view_test.exs

index fae0c07f009dfca23af1779d5ca0227179548502..2f1f7e627e7b078a9f5b8e1478398ec88ba7e9d2 100644 (file)
@@ -80,6 +80,7 @@ defmodule Pleroma.Web.AdminAPI.AccountView 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,
index 9e9de33f6167c615158440da34d0f6b3dd877a98..6114e12b14405db25a879c2a14fe2e233e98d7c5 100644 (file)
@@ -269,6 +269,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView 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,
index 1580ca448895df23ccb14ab0b31ab4478773dbdd..b199fa70450a7446e40cef7cb52913827db790f2 100644 (file)
@@ -877,7 +877,7 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest 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 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest 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 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest 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 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest 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 @@ defmodule Pleroma.Web.AdminAPI.UserControllerTest 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",
index 60881756d9b402a3d624f44b17d6239c66d10994..9af5887780baf0129d9d166d72da981484eb2b53 100644 (file)
@@ -83,6 +83,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
         tags: [],
         is_admin: false,
         is_moderator: false,
+        is_suggested: false,
         hide_favorites: true,
         hide_followers: false,
         hide_follows: false,
@@ -183,6 +184,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
         tags: [],
         is_admin: false,
         is_moderator: false,
+        is_suggested: false,
         hide_favorites: true,
         hide_followers: false,
         hide_follows: false,