2020-05-12 17:08:00 +02:00
|
|
|
# Pleroma: A lightweight social networking server
|
2021-01-13 07:49:20 +01:00
|
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
2020-05-12 17:08:00 +02:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.Preload.Providers.User do
|
2020-06-29 11:06:20 +02:00
|
|
|
alias Pleroma.User
|
2020-05-12 17:08:00 +02:00
|
|
|
alias Pleroma.Web.MastodonAPI.AccountView
|
|
|
|
alias Pleroma.Web.Preload.Providers.Provider
|
|
|
|
|
|
|
|
@behaviour Provider
|
2020-06-29 11:41:00 +02:00
|
|
|
@account_url_base "/api/v1/accounts"
|
2020-05-12 17:08:00 +02:00
|
|
|
|
|
|
|
@impl Provider
|
|
|
|
def generate_terms(%{user: user}) do
|
|
|
|
build_accounts_tag(%{}, user)
|
|
|
|
end
|
|
|
|
|
|
|
|
def generate_terms(_params), do: %{}
|
|
|
|
|
2020-06-29 11:06:20 +02:00
|
|
|
def build_accounts_tag(acc, %User{} = user) do
|
2020-05-12 17:08:00 +02:00
|
|
|
account_data = AccountView.render("show.json", %{user: user, for: user})
|
2020-06-29 11:41:00 +02:00
|
|
|
Map.put(acc, "#{@account_url_base}/#{user.id}", account_data)
|
2020-05-12 17:08:00 +02:00
|
|
|
end
|
2020-06-29 11:06:20 +02:00
|
|
|
|
|
|
|
def build_accounts_tag(acc, _), do: acc
|
2020-05-12 17:08:00 +02:00
|
|
|
end
|