Merge remote-tracking branch 'origin/develop' into feature/account-export
authorEgor Kislitsyn <egor@kislitsyn.com>
Fri, 30 Oct 2020 15:34:02 +0000 (19:34 +0400)
committerEgor Kislitsyn <egor@kislitsyn.com>
Fri, 30 Oct 2020 15:34:02 +0000 (19:34 +0400)
1  2 
CHANGELOG.md
config/description.exs
lib/pleroma/web/admin_api/controllers/admin_api_controller.ex
lib/pleroma/web/router.ex
test/pleroma/web/admin_api/controllers/admin_api_controller_test.exs

diff --cc CHANGELOG.md
index 23754257cb209036fd987a721c4a19bbea5c8294,11820d313a050b4c48952693445d402c1083e9a3..fb07124cc85f79fedee9f8f18530cea3cde690b2
@@@ -12,8 -12,8 +12,9 @@@ The format is based on [Keep a Changelo
  - Media preview proxy (requires `ffmpeg` and `ImageMagick` to be installed and media proxy to be enabled; see `:media_preview_proxy` config for more details).
  - Pleroma API: Importing the mutes users from CSV files.
  - Experimental websocket-based federation between Pleroma instances.
+ - Support pagination of blocks and mutes
  - App metrics: ability to restrict access to specified IP whitelist.
 +- Account backup
  - Configuration: Add `:instance, autofollowing_nicknames` setting to provide a way to make accounts automatically follow new users that register on the local Pleroma instance.
  
  ### Changed
Simple merge
index 0a27c58611319ef86b9e68df7575e0783ca1d9bb,df5817cfa4f44f8f2988e86fb85a9db4faba3335..5c2c282b3f8be3804579549ea7f2aef4fad67627
@@@ -30,7 -26,7 +26,7 @@@ defmodule Pleroma.Web.AdminAPI.AdminAPI
    plug(
      OAuthScopesPlug,
      %{scopes: ["read:accounts"], admin: true}
-     when action in [:list_users, :user_show, :right_get, :show_user_credentials, :create_backup]
 -    when action in [:right_get, :show_user_credentials]
++    when action in [:right_get, :show_user_credentials, :create_backup]
    )
  
    plug(
      json(conn, %{"status_visibility" => counters})
    end
  
 +  def create_backup(%{assigns: %{user: admin}} = conn, %{"nickname" => nickname}) do
 +    with %User{} = user <- User.get_by_nickname(nickname),
 +         {:ok, _} <- Pleroma.User.Backup.create(user, admin.id) do
 +      ModerationLog.insert_log(%{actor: admin, subject: user, action: "create_backup"})
 +
 +      json(conn, "")
 +    end
 +  end
 +
    defp page_params(params) do
-     {get_page(params["page"]), get_page_size(params["page_size"])}
-   end
-   defp get_page(page_string) when is_nil(page_string), do: 1
-   defp get_page(page_string) do
-     case Integer.parse(page_string) do
-       {page, _} -> page
-       :error -> 1
-     end
-   end
-   defp get_page_size(page_size_string) when is_nil(page_size_string), do: @users_page_size
-   defp get_page_size(page_size_string) do
-     case Integer.parse(page_size_string) do
-       {page_size, _} -> page_size
-       :error -> @users_page_size
-     end
+     {
+       fetch_integer_param(params, "page", 1),
+       fetch_integer_param(params, "page_size", @users_page_size)
+     }
    end
  end
index 1126536a35b5ec81ec3ce6c931d3412ffa06e373,76ca2c9b51ab3a9be87b109dbba5a2e9a6fb5af2..9592d0f38cceffe41d8075d5b62de3e2dcd8fd91
@@@ -128,19 -148,8 +148,8 @@@ defmodule Pleroma.Web.Router d
  
    scope "/api/pleroma/admin", Pleroma.Web.AdminAPI do
      pipe_through(:admin_api)
-     post("/backups", AdminAPIController, :create_backup)
-     post("/users/follow", AdminAPIController, :user_follow)
-     post("/users/unfollow", AdminAPIController, :user_unfollow)
--
++    
      put("/users/disable_mfa", AdminAPIController, :disable_mfa)
-     delete("/users", AdminAPIController, :user_delete)
-     post("/users", AdminAPIController, :users_create)
-     patch("/users/:nickname/toggle_activation", AdminAPIController, :user_toggle_activation)
-     patch("/users/activate", AdminAPIController, :user_activate)
-     patch("/users/deactivate", AdminAPIController, :user_deactivate)
-     patch("/users/approve", AdminAPIController, :user_approve)
      put("/users/tag", AdminAPIController, :tag_users)
      delete("/users/tag", AdminAPIController, :untag_users)
  
      get("/chats/:id", ChatController, :show)
      get("/chats/:id/messages", ChatController, :messages)
      delete("/chats/:id/messages/:message_id", ChatController, :delete_message)
++
++    post("/backups", AdminAPIController, :create_backup)
    end
  
    scope "/api/pleroma/emoji", Pleroma.Web.PleromaAPI do