logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

backup_controller.ex (950B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.PleromaAPI.BackupController do
  5. use Pleroma.Web, :controller
  6. alias Pleroma.User.Backup
  7. alias Pleroma.Web.Plugs.OAuthScopesPlug
  8. action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
  9. plug(OAuthScopesPlug, %{scopes: ["read:backups"]} when action in [:index, :create])
  10. plug(Pleroma.Web.ApiSpec.CastAndValidate)
  11. defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.PleromaBackupOperation
  12. def index(%{assigns: %{user: user}} = conn, _params) do
  13. backups = Backup.list(user)
  14. render(conn, "index.json", backups: backups)
  15. end
  16. def create(%{assigns: %{user: user}} = conn, _params) do
  17. with {:ok, _} <- Backup.create(user) do
  18. backups = Backup.list(user)
  19. render(conn, "index.json", backups: backups)
  20. end
  21. end
  22. end