assert user.note_count == 1
assert user.follower_count == 1
assert user.following_count == 1
- refute user.deactivated
+ assert user.is_active
with_mock Pleroma.Web.Federator,
publish: fn _ -> nil end,
ObanHelpers.perform_all()
- assert User.get_by_nickname(user.nickname).deactivated
+ refute User.get_by_nickname(user.nickname).is_active
log_entry = Repo.one(ModerationLog)
assert json_response(conn, 200) == [user.nickname]
user = Repo.get(User, user.id)
- assert user.deactivated
+ refute user.is_active
assert user.avatar == %{}
assert user.banner == %{}
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"])
- user2 = insert(:user, approval_pending: true, registration_reason: "I'm a chill dude")
+ user2 = insert(:user, is_approved: false, registration_reason: "I'm a chill dude")
conn = get(conn, "/api/pleroma/admin/users?page=1")
user2,
%{
"local" => true,
- "approval_pending" => true,
+ "is_approved" => false,
"registration_reason" => "I'm a chill dude",
"actor_type" => "Person"
}
"roles" => %{"admin" => true, "moderator" => false}
}),
user_response(old_admin, %{
- "deactivated" => false,
+ "is_active" => true,
"roles" => %{"admin" => true, "moderator" => false}
})
]
end
test "only unconfirmed users", %{conn: conn} do
- sad_user = insert(:user, nickname: "sadboy", confirmation_pending: true)
- old_user = insert(:user, nickname: "oldboy", confirmation_pending: true)
+ sad_user = insert(:user, nickname: "sadboy", is_confirmed: false)
+ old_user = insert(:user, nickname: "oldboy", is_confirmed: false)
- insert(:user, nickname: "happyboy", approval_pending: false)
- insert(:user, confirmation_pending: false)
+ insert(:user, nickname: "happyboy", is_approved: true)
+ insert(:user, is_confirmed: true)
result =
conn
users =
Enum.map([old_user, sad_user], fn user ->
user_response(user, %{
- "confirmation_pending" => true,
- "approval_pending" => false
+ "is_confirmed" => false,
+ "is_approved" => true
})
end)
|> Enum.sort_by(& &1["nickname"])
user =
insert(:user,
nickname: "sadboy",
- approval_pending: true,
+ is_approved: false,
registration_reason: "Plz let me in!"
)
- insert(:user, nickname: "happyboy", approval_pending: false)
+ insert(:user, nickname: "happyboy", is_approved: true)
conn = get(conn, "/api/pleroma/admin/users?filters=need_approval")
users = [
user_response(
user,
- %{"approval_pending" => true, "registration_reason" => "Plz let me in!"}
+ %{"is_approved" => false, "registration_reason" => "Plz let me in!"}
)
]
users =
[
user_response(admin, %{
- "deactivated" => false,
+ "is_active" => true,
"roles" => %{"admin" => true, "moderator" => false}
}),
user_response(second_admin, %{
- "deactivated" => false,
+ "is_active" => true,
"roles" => %{"admin" => true, "moderator" => false}
})
]
"page_size" => 50,
"users" => [
user_response(moderator, %{
- "deactivated" => false,
+ "is_active" => true,
"roles" => %{"admin" => false, "moderator" => true}
})
]
end
test "`active` filters out users pending approval", %{token: token} do
- insert(:user, approval_pending: true)
- %{id: user_id} = insert(:user, approval_pending: false)
+ insert(:user, is_approved: false)
+ %{id: user_id} = insert(:user, is_approved: true)
%{id: admin_id} = token.user
conn =
test "it works with multiple filters" do
admin = insert(:user, nickname: "john", is_admin: true)
token = insert(:oauth_admin_token, user: admin)
- user = insert(:user, nickname: "bob", local: false, deactivated: true)
+ user = insert(:user, nickname: "bob", local: false, is_active: false)
- insert(:user, nickname: "ken", local: true, deactivated: true)
- insert(:user, nickname: "bobb", local: false, deactivated: false)
+ insert(:user, nickname: "ken", local: true, is_active: false)
+ insert(:user, nickname: "bobb", local: false, is_active: true)
conn =
build_conn()
end
test "PATCH /api/pleroma/admin/users/activate", %{admin: admin, conn: conn} do
- user_one = insert(:user, deactivated: true)
- user_two = insert(:user, deactivated: true)
+ user_one = insert(:user, is_active: false)
+ user_two = insert(:user, is_active: false)
conn =
patch(
)
response = json_response(conn, 200)
- assert Enum.map(response["users"], & &1["deactivated"]) == [false, false]
+ assert Enum.map(response["users"], & &1["is_active"]) == [true, true]
log_entry = Repo.one(ModerationLog)
end
test "PATCH /api/pleroma/admin/users/deactivate", %{admin: admin, conn: conn} do
- user_one = insert(:user, deactivated: false)
- user_two = insert(:user, deactivated: false)
+ user_one = insert(:user, is_active: true)
+ user_two = insert(:user, is_active: true)
conn =
patch(
)
response = json_response(conn, 200)
- assert Enum.map(response["users"], & &1["deactivated"]) == [true, true]
+ assert Enum.map(response["users"], & &1["is_active"]) == [false, false]
log_entry = Repo.one(ModerationLog)
end
test "PATCH /api/pleroma/admin/users/approve", %{admin: admin, conn: conn} do
- user_one = insert(:user, approval_pending: true)
- user_two = insert(:user, approval_pending: true)
+ user_one = insert(:user, is_approved: false)
+ user_two = insert(:user, is_approved: false)
conn =
patch(
)
response = json_response(conn, 200)
- assert Enum.map(response["users"], & &1["approval_pending"]) == [false, false]
+ assert Enum.map(response["users"], & &1["is_approved"]) == [true, true]
log_entry = Repo.one(ModerationLog)
assert json_response(conn, 200) ==
user_response(
user,
- %{"deactivated" => !user.deactivated}
+ %{"is_active" => !user.is_active}
)
log_entry = Repo.one(ModerationLog)
defp user_response(user, attrs \\ %{}) do
%{
- "deactivated" => user.deactivated,
+ "is_active" => user.is_active,
"id" => user.id,
"email" => user.email,
"nickname" => user.nickname,
"tags" => [],
"avatar" => User.avatar_url(user) |> MediaProxy.url(),
"display_name" => HTML.strip_tags(user.name || user.nickname),
- "confirmation_pending" => false,
- "approval_pending" => false,
+ "is_confirmed" => true,
+ "is_approved" => true,
"url" => user.ap_id,
"registration_reason" => nil,
"actor_type" => "Person"