From: Maxim Filippov Date: Sun, 24 Nov 2019 16:46:18 +0000 (+0900) Subject: Merge branch 'develop' into feature/admin-api-list-statuses-for-a-given-instance X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=82f4e4760ed594fd858e36444dfb01f27fa8068c;p=akkoma Merge branch 'develop' into feature/admin-api-list-statuses-for-a-given-instance --- 82f4e4760ed594fd858e36444dfb01f27fa8068c diff --cc CHANGELOG.md index 3e22d7acb,8db8039b8..68a9d93d8 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@@ -69,7 -70,7 +70,8 @@@ The format is based on [Keep a Changelo - Mastodon API: Add the `recipients` parameter to `GET /api/v1/conversations` - Configuration: `feed` option for user atom feed. - Pleroma API: Add Emoji reactions +- Admin API: Add `/api/pleroma/admin/instances/:instance/statuses` - lists all statuses from a given instance + - Admin API: `PATCH /api/pleroma/users/confirm_email` to confirm email for multiple users, `PATCH /api/pleroma/users/resend_confirmation_email` to resend confirmation email for multiple users ### Fixed diff --cc lib/pleroma/web/router.ex index 12b676065,0b54f4ab7..e6c4f6f14 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@@ -178,8 -178,9 +178,11 @@@ defmodule Pleroma.Web.Router d get("/users/:nickname", AdminAPIController, :user_show) get("/users/:nickname/statuses", AdminAPIController, :list_user_statuses) + get("/instances/:instance/statuses", AdminAPIController, :list_instance_statuses) + + patch("/users/confirm_email", AdminAPIController, :confirm_email) + patch("/users/resend_confirmation_email", AdminAPIController, :resend_confirmation_email) + get("/reports", AdminAPIController, :list_reports) get("/grouped_reports", AdminAPIController, :list_grouped_reports) get("/reports/:id", AdminAPIController, :report_show) diff --cc test/web/admin_api/admin_api_controller_test.exs index 471477f2c,9b4f359dc..bb2ca6a62 --- a/test/web/admin_api/admin_api_controller_test.exs +++ b/test/web/admin_api/admin_api_controller_test.exs @@@ -2840,42 -2862,67 +2862,104 @@@ defmodule Pleroma.Web.AdminAPI.AdminAPI end end + describe "instances" do + test "GET /instances/:instance/statuses" do + admin = insert(:user, is_admin: true) + user = insert(:user, local: false, nickname: "archaeme@archae.me") + user2 = insert(:user, local: false, nickname: "test@test.com") + insert_pair(:note_activity, user: user) + insert(:note_activity, user: user2) + + conn = + build_conn() + |> assign(:user, admin) + |> get("/api/pleroma/admin/instances/archae.me/statuses") + + response = json_response(conn, 200) + + assert length(response) == 2 + + conn = + build_conn() + |> assign(:user, admin) + |> get("/api/pleroma/admin/instances/test.com/statuses") + + response = json_response(conn, 200) + + assert length(response) == 1 + + conn = + build_conn() + |> assign(:user, admin) + |> get("/api/pleroma/admin/instances/nonexistent.com/statuses") + + response = json_response(conn, 200) + + assert length(response) == 0 + end + end ++ + describe "PATCH /confirm_email" do + setup %{conn: conn} do + admin = insert(:user, is_admin: true) + + %{conn: assign(conn, :user, admin), admin: admin} + end + + test "it confirms emails of two users", %{admin: admin} do + [first_user, second_user] = insert_pair(:user, confirmation_pending: true) + + assert first_user.confirmation_pending == true + assert second_user.confirmation_pending == true + + build_conn() + |> assign(:user, admin) + |> patch("/api/pleroma/admin/users/confirm_email", %{ + nicknames: [ + first_user.nickname, + second_user.nickname + ] + }) + + assert first_user.confirmation_pending == true + assert second_user.confirmation_pending == true + + log_entry = Repo.one(ModerationLog) + + assert ModerationLog.get_log_entry_message(log_entry) == + "@#{admin.nickname} confirmed email for users: @#{first_user.nickname}, @#{ + second_user.nickname + }" + end + end + + describe "PATCH /resend_confirmation_email" do + setup %{conn: conn} do + admin = insert(:user, is_admin: true) + + %{conn: assign(conn, :user, admin), admin: admin} + end + + test "it resend emails for two users", %{admin: admin} do + [first_user, second_user] = insert_pair(:user, confirmation_pending: true) + + build_conn() + |> assign(:user, admin) + |> patch("/api/pleroma/admin/users/resend_confirmation_email", %{ + nicknames: [ + first_user.nickname, + second_user.nickname + ] + }) + + log_entry = Repo.one(ModerationLog) + + assert ModerationLog.get_log_entry_message(log_entry) == + "@#{admin.nickname} re-sent confirmation email for users: @#{first_user.nickname}, @#{ + second_user.nickname + }" + end + end end # Needed for testing