From: Maxim Filippov Date: Fri, 18 Oct 2019 08:24:29 +0000 (+0200) Subject: Merge branch 'develop' into feature/relay-list X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=2473702be22a44070fcff439ac901f5b9bb0586a;p=akkoma Merge branch 'develop' into feature/relay-list --- 2473702be22a44070fcff439ac901f5b9bb0586a diff --cc CHANGELOG.md index 2e7817a54,f9f84b056..f91bf63c4 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@@ -17,7 -17,9 +17,10 @@@ The format is based on [Keep a Changelo - Authentication: Added rate limit for password-authorized actions / login existence checks - Metadata Link: Atom syndication Feed - Mix task to re-count statuses for all users (`mix pleroma.count_statuses`) + - Mastodon API: Add `exclude_visibilities` parameter to the timeline and notification endpoints + - Admin API: `/users/:nickname/toggle_activation` endpoint is now deprecated in favor of: `/users/activate`, `/users/deactivate`, both accept `nicknames` array + - Admin API: `POST/DELETE /api/pleroma/admin/users/:nickname/permission_group/:permission_group` are deprecated in favor of: `POST/DELETE /api/pleroma/admin/users/permission_group/:permission_group` (both accept `nicknames` array), `DELETE /api/pleroma/admin/users` (`nickname` query param or `nickname` sent in JSON body) is deprecated in favor of: `DELETE /api/pleroma/admin/users` (`nicknames` query array param or `nicknames` sent in JSON body). +- Admin API: Add `GET /api/pleroma/admin/relay` endpoint - lists all followed relays ### Changed - **Breaking:** Elixir >=1.8 is now required (was >= 1.7) diff --cc lib/pleroma/web/admin_api/admin_api_controller.ex index 24dda75a9,ab0d0fe0a..b6d3f79c8 --- a/lib/pleroma/web/admin_api/admin_api_controller.ex +++ b/lib/pleroma/web/admin_api/admin_api_controller.ex @@@ -378,39 -477,10 +477,20 @@@ defmodule Pleroma.Web.AdminAPI.AdminAPI json(conn, info) end - def right_delete(conn, _) do - render_error(conn, :not_found, "No such permission_group") - end - - def set_activation_status(%{assigns: %{user: admin}} = conn, %{ - "nickname" => nickname, - "status" => status - }) do - with {:ok, status} <- Ecto.Type.cast(:boolean, status), - %User{} = user <- User.get_cached_by_nickname(nickname), - {:ok, _} <- User.deactivate(user, !status) do - action = if(user.info.deactivated, do: "activate", else: "deactivate") - - ModerationLog.insert_log(%{ - actor: admin, - subject: user, - action: action - }) - - json_response(conn, :no_content, "") - end + def right_delete(%{assigns: %{user: %{nickname: nickname}}} = conn, %{"nickname" => nickname}) do + render_error(conn, :forbidden, "You can't revoke your own admin status.") end + def relay_list(conn, _params) do + with {:ok, list} <- Relay.list() do + json(conn, %{relays: list}) + else + _ -> + conn + |> put_status(500) + end + end + def relay_follow(%{assigns: %{user: admin}} = conn, %{"relay_url" => target}) do with {:ok, _message} <- Relay.follow(target) do ModerationLog.insert_log(%{ diff --cc lib/pleroma/web/router.ex index 8cc967af9,80651f3ff..0c649cde5 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@@ -150,9 -153,14 +153,15 @@@ defmodule Pleroma.Web.Router d :right_delete ) - put("/users/:nickname/activation_status", AdminAPIController, :set_activation_status) + post("/users/permission_group/:permission_group", AdminAPIController, :right_add_multiple) + + delete( + "/users/permission_group/:permission_group", + AdminAPIController, + :right_delete_multiple + ) + get("/relay", AdminAPIController, :relay_list) post("/relay", AdminAPIController, :relay_follow) delete("/relay", AdminAPIController, :relay_unfollow) diff --cc test/web/admin_api/admin_api_controller_test.exs index d7dce2da4,645b79f57..9da4940be --- a/test/web/admin_api/admin_api_controller_test.exs +++ b/test/web/admin_api/admin_api_controller_test.exs @@@ -17,14 -17,8 +17,14 @@@ defmodule Pleroma.Web.AdminAPI.AdminAPI alias Pleroma.Web.MediaProxy import Pleroma.Factory + setup_all do + Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) + + :ok + end + - describe "/api/pleroma/admin/users" do - test "Delete" do + describe "DELETE /api/pleroma/admin/users" do + test "single user" do admin = insert(:user, info: %{is_admin: true}) user = insert(:user)