}
```
+## `DELETE /api/v1/pleroma/admin/instances/:instance`
+
+### Delete all users and activities from a remote instance
+
+Note: this will trigger a job to remove instance content in the background.
+It may take some time.
+
+- Params:
+ - `instance`: remote instance host
+- Response:
+ - The `instance` name as a string
+
+```json
+"lain.com"
+```
+
## `GET /api/v1/pleroma/admin/statuses`
### Retrives all latest statuses
import Pleroma.Web.ControllerHelper, only: [fetch_integer_param: 3]
+ alias Pleroma.Instances.Instance
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.AdminAPI
alias Pleroma.Web.Plugs.OAuthScopesPlug
when action in [:list_instance_statuses]
)
+ plug(
+ OAuthScopesPlug,
+ %{scopes: ["admin:write:accounts", "admin:write:statuses"]}
+ when action in [:delete_instance]
+ )
+
action_fallback(AdminAPI.FallbackController)
def list_instance_statuses(conn, %{"instance" => instance} = params) do
|> render("index.json", %{total: result[:total], activities: result[:items], as: :activity})
end
+ def delete_instance(conn, %{"instance" => instance}) do
+ with {:ok, _job} <- Instance.delete_users_and_activities(instance) do
+ json(conn, instance)
+ end
+ end
+
defp page_params(params) do
{
fetch_integer_param(params, "page", 1),
get("/users/:nickname/chats", AdminAPIController, :list_user_chats)
get("/instances/:instance/statuses", InstanceController, :list_instance_statuses)
+ delete("/instances/:instance", InstanceController, :delete_instance)
get("/instance_document/:name", InstanceDocumentController, :show)
patch("/instance_document/:name", InstanceDocumentController, :update)
import Pleroma.Factory
+ alias Pleroma.Repo
+ alias Pleroma.Tests.ObanHelpers
alias Pleroma.Web.CommonAPI
setup_all do
assert length(activities) == 3
end
end
+
+ test "DELETE /instances/:instance", %{conn: conn} do
+ user = insert(:user, nickname: "lain@lain.com")
+ post = insert(:note_activity, user: user)
+
+ response =
+ conn
+ |> delete("/api/pleroma/admin/instances/lain.com")
+ |> json_response(200)
+
+ [:ok] = ObanHelpers.perform_all()
+
+ assert response == "lain.com"
+ refute Repo.reload(user).is_active
+ refute Repo.reload(post)
+ end
end