aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/preload/user.ex
blob: 3a244845b499f0d9221815465eeafa0f32726240 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Web.Preload.Providers.User do
  alias Pleroma.Web.MastodonAPI.AccountView
  alias Pleroma.Web.Preload.Providers.Provider

  @behaviour Provider
  @account_url :"/api/v1/accounts"

  @impl Provider
  def generate_terms(%{user: user}) do
    build_accounts_tag(%{}, user)
  end

  def generate_terms(_params), do: %{}

  def build_accounts_tag(acc, nil), do: acc

  def build_accounts_tag(acc, user) do
    account_data = AccountView.render("show.json", %{user: user, for: user})
    Map.put(acc, @account_url, account_data)
  end
end