AdminAPI: Return approval_pending
with users
This commit is contained in:
parent
a1570ba6ad
commit
b750129da1
3 changed files with 42 additions and 3 deletions
|
@ -47,6 +47,8 @@ Configuration options:
|
|||
"tags": array,
|
||||
"avatar": string,
|
||||
"display_name": string,
|
||||
"confirmation_pending": bool,
|
||||
"approval_pending": bool,
|
||||
"registration_reason": string,
|
||||
},
|
||||
...
|
||||
|
|
|
@ -77,6 +77,7 @@ def render("show.json", %{user: user}) do
|
|||
"roles" => User.roles(user),
|
||||
"tags" => user.tags || [],
|
||||
"confirmation_pending" => user.confirmation_pending,
|
||||
"approval_pending" => user.approval_pending,
|
||||
"url" => user.uri || user.ap_id,
|
||||
"registration_reason" => user.registration_reason
|
||||
}
|
||||
|
|
|
@ -338,6 +338,7 @@ test "Show", %{conn: conn} do
|
|||
"avatar" => User.avatar_url(user) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(user.name || user.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
}
|
||||
|
@ -602,8 +603,8 @@ test "/api/pleroma/admin/users/:nickname/password_reset", %{conn: conn} do
|
|||
|
||||
describe "GET /api/pleroma/admin/users" do
|
||||
test "renders users array for the first page", %{conn: conn, admin: admin} do
|
||||
user =
|
||||
insert(:user, local: false, tags: ["foo", "bar"], registration_reason: "I'm a chill dude")
|
||||
user = insert(:user, local: false, tags: ["foo", "bar"])
|
||||
user2 = insert(:user, approval_pending: true, registration_reason: "I'm a chill dude")
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/users?page=1")
|
||||
|
||||
|
@ -619,6 +620,7 @@ test "renders users array for the first page", %{conn: conn, admin: admin} do
|
|||
"avatar" => User.avatar_url(admin) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(admin.name || admin.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => admin.ap_id,
|
||||
"registration_reason" => nil
|
||||
},
|
||||
|
@ -632,14 +634,29 @@ test "renders users array for the first page", %{conn: conn, admin: admin} do
|
|||
"avatar" => User.avatar_url(user) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(user.name || user.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
},
|
||||
%{
|
||||
"deactivated" => user2.deactivated,
|
||||
"id" => user2.id,
|
||||
"nickname" => user2.nickname,
|
||||
"roles" => %{"admin" => false, "moderator" => false},
|
||||
"local" => true,
|
||||
"tags" => [],
|
||||
"avatar" => User.avatar_url(user2) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(user2.name || user2.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => true,
|
||||
"url" => user2.ap_id,
|
||||
"registration_reason" => "I'm a chill dude"
|
||||
}
|
||||
]
|
||||
|> Enum.sort_by(& &1["nickname"])
|
||||
|
||||
assert json_response(conn, 200) == %{
|
||||
"count" => 2,
|
||||
"count" => 3,
|
||||
"page_size" => 50,
|
||||
"users" => users
|
||||
}
|
||||
|
@ -706,6 +723,7 @@ test "regular search", %{conn: conn} do
|
|||
"avatar" => User.avatar_url(user) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(user.name || user.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
}
|
||||
|
@ -733,6 +751,7 @@ test "search by domain", %{conn: conn} do
|
|||
"avatar" => User.avatar_url(user) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(user.name || user.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
}
|
||||
|
@ -760,6 +779,7 @@ test "search by full nickname", %{conn: conn} do
|
|||
"avatar" => User.avatar_url(user) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(user.name || user.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
}
|
||||
|
@ -787,6 +807,7 @@ test "search by display name", %{conn: conn} do
|
|||
"avatar" => User.avatar_url(user) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(user.name || user.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
}
|
||||
|
@ -814,6 +835,7 @@ test "search by email", %{conn: conn} do
|
|||
"avatar" => User.avatar_url(user) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(user.name || user.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
}
|
||||
|
@ -841,6 +863,7 @@ test "regular search with page size", %{conn: conn} do
|
|||
"avatar" => User.avatar_url(user) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(user.name || user.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
}
|
||||
|
@ -863,6 +886,7 @@ test "regular search with page size", %{conn: conn} do
|
|||
"avatar" => User.avatar_url(user2) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(user2.name || user2.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user2.ap_id,
|
||||
"registration_reason" => nil
|
||||
}
|
||||
|
@ -897,6 +921,7 @@ test "only local users" do
|
|||
"avatar" => User.avatar_url(user) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(user.name || user.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
}
|
||||
|
@ -924,6 +949,7 @@ test "only local users with no query", %{conn: conn, admin: old_admin} do
|
|||
"avatar" => User.avatar_url(user) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(user.name || user.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
},
|
||||
|
@ -937,6 +963,7 @@ test "only local users with no query", %{conn: conn, admin: old_admin} do
|
|||
"avatar" => User.avatar_url(admin) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(admin.name || admin.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => admin.ap_id,
|
||||
"registration_reason" => nil
|
||||
},
|
||||
|
@ -950,6 +977,7 @@ test "only local users with no query", %{conn: conn, admin: old_admin} do
|
|||
"avatar" => User.avatar_url(old_admin) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(old_admin.name || old_admin.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => old_admin.ap_id,
|
||||
"registration_reason" => nil
|
||||
}
|
||||
|
@ -982,6 +1010,7 @@ test "load only admins", %{conn: conn, admin: admin} do
|
|||
"avatar" => User.avatar_url(admin) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(admin.name || admin.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => admin.ap_id,
|
||||
"registration_reason" => nil
|
||||
},
|
||||
|
@ -995,6 +1024,7 @@ test "load only admins", %{conn: conn, admin: admin} do
|
|||
"avatar" => User.avatar_url(second_admin) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(second_admin.name || second_admin.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => second_admin.ap_id,
|
||||
"registration_reason" => nil
|
||||
}
|
||||
|
@ -1029,6 +1059,7 @@ test "load only moderators", %{conn: conn} do
|
|||
"avatar" => User.avatar_url(moderator) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(moderator.name || moderator.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => moderator.ap_id,
|
||||
"registration_reason" => nil
|
||||
}
|
||||
|
@ -1056,6 +1087,7 @@ test "load users with tags list", %{conn: conn} do
|
|||
"avatar" => User.avatar_url(user1) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(user1.name || user1.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user1.ap_id,
|
||||
"registration_reason" => nil
|
||||
},
|
||||
|
@ -1069,6 +1101,7 @@ test "load users with tags list", %{conn: conn} do
|
|||
"avatar" => User.avatar_url(user2) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(user2.name || user2.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user2.ap_id,
|
||||
"registration_reason" => nil
|
||||
}
|
||||
|
@ -1110,6 +1143,7 @@ test "it works with multiple filters" do
|
|||
"avatar" => User.avatar_url(user) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(user.name || user.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
}
|
||||
|
@ -1136,6 +1170,7 @@ test "it omits relay user", %{admin: admin, conn: conn} do
|
|||
"avatar" => User.avatar_url(admin) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(admin.name || admin.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => admin.ap_id,
|
||||
"registration_reason" => nil
|
||||
}
|
||||
|
@ -1200,6 +1235,7 @@ test "PATCH /api/pleroma/admin/users/:nickname/toggle_activation", %{admin: admi
|
|||
"avatar" => User.avatar_url(user) |> MediaProxy.url(),
|
||||
"display_name" => HTML.strip_tags(user.name || user.nickname),
|
||||
"confirmation_pending" => false,
|
||||
"approval_pending" => false,
|
||||
"url" => user.ap_id,
|
||||
"registration_reason" => nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue