User preloader: Put user info at correct key
This commit is contained in:
parent
a2002ebb63
commit
a19f8778af
2 changed files with 13 additions and 12 deletions
|
|
@ -3,11 +3,12 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.Preload.Providers.User do
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.MastodonAPI.AccountView
|
||||
alias Pleroma.Web.Preload.Providers.Provider
|
||||
|
||||
@behaviour Provider
|
||||
@account_url :"/api/v1/accounts"
|
||||
@account_url_base :"/api/v1/accounts"
|
||||
|
||||
@impl Provider
|
||||
def generate_terms(%{user: user}) do
|
||||
|
|
@ -16,10 +17,10 @@ defmodule Pleroma.Web.Preload.Providers.User do
|
|||
|
||||
def generate_terms(_params), do: %{}
|
||||
|
||||
def build_accounts_tag(acc, nil), do: acc
|
||||
|
||||
def build_accounts_tag(acc, user) do
|
||||
def build_accounts_tag(acc, %User{} = user) do
|
||||
account_data = AccountView.render("show.json", %{user: user, for: user})
|
||||
Map.put(acc, @account_url, account_data)
|
||||
Map.put(acc, :"#{@account_url_base}/#{user.id}", account_data)
|
||||
end
|
||||
|
||||
def build_accounts_tag(acc, _), do: acc
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue