logo

pleroma

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

user.ex (764B)


  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.Preload.Providers.User do
  5. alias Pleroma.User
  6. alias Pleroma.Web.MastodonAPI.AccountView
  7. alias Pleroma.Web.Preload.Providers.Provider
  8. @behaviour Provider
  9. @account_url_base "/api/v1/accounts"
  10. @impl Provider
  11. def generate_terms(%{user: user}) do
  12. build_accounts_tag(%{}, user)
  13. end
  14. def generate_terms(_params), do: %{}
  15. def build_accounts_tag(acc, %User{} = user) do
  16. account_data = AccountView.render("show.json", %{user: user, for: user})
  17. Map.put(acc, "#{@account_url_base}/#{user.id}", account_data)
  18. end
  19. def build_accounts_tag(acc, _), do: acc
  20. end