1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.AdminAPI.InstanceController do
6 use Pleroma.Web, :controller
8 import Pleroma.Web.ControllerHelper, only: [fetch_integer_param: 3]
10 alias Pleroma.Instances.Instance
11 alias Pleroma.Web.ActivityPub.ActivityPub
12 alias Pleroma.Web.AdminAPI
13 alias Pleroma.Web.Plugs.OAuthScopesPlug
21 %{scopes: ["admin:read:statuses"]}
22 when action in [:list_statuses]
27 %{scopes: ["admin:write:accounts", "admin:write:statuses"]}
28 when action in [:delete]
31 action_fallback(AdminAPI.FallbackController)
33 def list_statuses(conn, %{"instance" => instance} = params) do
34 with_reblogs = params["with_reblogs"] == "true" || params["with_reblogs"] == true
35 {page, page_size} = page_params(params)
38 ActivityPub.fetch_statuses(nil, %{
41 offset: (page - 1) * page_size,
42 exclude_reblogs: not with_reblogs,
47 |> put_view(AdminAPI.StatusView)
48 |> render("index.json", %{total: result[:total], activities: result[:items], as: :activity})
51 def delete(conn, %{"instance" => instance}) do
52 with {:ok, _job} <- Instance.delete_users_and_activities(instance) do
57 defp page_params(params) do
59 fetch_integer_param(params, "page", 1),
60 fetch_integer_param(params, "page_size", @default_page_size)