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.PleromaAPI.BackupView do
8 alias Pleroma.User.Backup
9 alias Pleroma.Web.CommonAPI.Utils
11 def render("show.json", %{backup: %Backup{} = backup}) do
14 content_type: backup.content_type,
15 url: download_url(backup),
16 file_size: backup.file_size,
17 processed: backup.processed,
18 inserted_at: Utils.to_masto_date(backup.inserted_at)
22 def render("index.json", %{backups: backups}) do
23 render_many(backups, __MODULE__, "show.json")
26 def download_url(%Backup{file_name: file_name}) do
27 Pleroma.Upload.base_url() <> "/backups/" <> file_name