defmodule Pleroma.Web.TwitterAPI.UserView do
use Pleroma.Web, :view
- alias Pleroma.User
alias Pleroma.Formatter
+ alias Pleroma.HTML
+ alias Pleroma.User
alias Pleroma.Web.CommonAPI.Utils
alias Pleroma.Web.MediaProxy
- alias Pleroma.HTML
def render("show.json", %{user: user = %User{}} = assigns) do
render_one(user, Pleroma.Web.TwitterAPI.UserView, "user.json", assigns)
"fields" => fields,
# Pleroma extension
- "pleroma" => %{
- "confirmation_pending" => user_info.confirmation_pending,
- "tags" => user.tags
- }
+ "pleroma" =>
+ %{
+ "confirmation_pending" => user_info.confirmation_pending,
+ "tags" => user.tags
+ }
+ |> maybe_with_follow_request_count(user, for_user)
}
data =
end
end
+ defp maybe_with_follow_request_count(data, %User{id: id, info: %{locked: true}} = user, %User{
+ id: id
+ }) do
+ Map.put(data, "follow_request_count", user.info.follow_request_count)
+ end
+
+ defp maybe_with_follow_request_count(data, _, _), do: data
+
defp maybe_with_role(data, %User{id: id} = user, %User{id: id}) do
Map.merge(data, %{"role" => role(user), "show_role" => user.info.show_role})
end