From: Egor Kislitsyn Date: Fri, 30 Oct 2020 15:34:02 +0000 (+0400) Subject: Merge remote-tracking branch 'origin/develop' into feature/account-export X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=d2113428c027580f1cd4854f6610d64ee9643fd2;p=akkoma Merge remote-tracking branch 'origin/develop' into feature/account-export --- d2113428c027580f1cd4854f6610d64ee9643fd2 diff --cc CHANGELOG.md index 23754257c,11820d313..fb07124cc --- a/CHANGELOG.md +++ b/CHANGELOG.md @@@ -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 diff --cc lib/pleroma/web/admin_api/controllers/admin_api_controller.ex index 0a27c5861,df5817cfa..5c2c282b3 --- a/lib/pleroma/web/admin_api/controllers/admin_api_controller.ex +++ b/lib/pleroma/web/admin_api/controllers/admin_api_controller.ex @@@ -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( @@@ -683,34 -441,10 +441,19 @@@ 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 diff --cc lib/pleroma/web/router.ex index 1126536a3,76ca2c9b5..9592d0f38 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@@ -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) @@@ -225,6 -243,6 +243,8 @@@ 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