7b28f7c720a87c82189e72661dd5ea38cbe7de53
[akkoma] / lib / pleroma / web / admin_api / controllers / media_proxy_cache_controller.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.AdminAPI.MediaProxyCacheController do
6 use Pleroma.Web, :controller
7
8 alias Pleroma.Plugs.OAuthScopesPlug
9 alias Pleroma.Web.ApiSpec.Admin, as: Spec
10
11 plug(Pleroma.Web.ApiSpec.CastAndValidate)
12
13 plug(
14 OAuthScopesPlug,
15 %{scopes: ["read:media_proxy_caches"], admin: true} when action in [:index]
16 )
17
18 plug(
19 OAuthScopesPlug,
20 %{scopes: ["write:media_proxy_caches"], admin: true} when action in [:purge, :delete]
21 )
22
23 action_fallback(Pleroma.Web.AdminAPI.FallbackController)
24
25 defdelegate open_api_operation(action), to: Spec.MediaProxyCacheOperation
26
27 def index(%{assigns: %{user: _}} = conn, _) do
28 render(conn, "index.json", urls: [])
29 end
30
31 def delete(%{assigns: %{user: _}, body_params: %{urls: urls}} = conn, _) do
32 render(conn, "index.json", urls: urls)
33 end
34
35 def purge(%{assigns: %{user: _}, body_params: %{urls: urls, ban: _ban}} = conn, _) do
36 render(conn, "index.json", urls: urls)
37 end
38 end