1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 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.Web.ActivityPub.ActivityPub
11 alias Pleroma.Web.AdminAPI
12 alias Pleroma.Web.Plugs.OAuthScopesPlug
20 %{scopes: ["admin:read:statuses"]}
21 when action in [:list_instance_statuses]
24 action_fallback(AdminAPI.FallbackController)
26 def list_instance_statuses(conn, %{"instance" => instance} = params) do
27 with_reblogs = params["with_reblogs"] == "true" || params["with_reblogs"] == true
28 {page, page_size} = page_params(params)
31 ActivityPub.fetch_statuses(nil, %{
34 offset: (page - 1) * page_size,
35 exclude_reblogs: not with_reblogs,
40 |> put_view(AdminAPI.StatusView)
41 |> render("index.json", %{total: result[:total], activities: result[:items], as: :activity})
44 defp page_params(params) do
46 fetch_integer_param(params, "page", 1),
47 fetch_integer_param(params, "page_size", @default_page_size)