summaryrefslogtreecommitdiff
path: root/lib/pleroma/web/mastodon_api/views/suggestion_view.ex
blob: d3df4ef3fbb0c8da8ce5b243d69150c0af2d63e4 (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
26
27
28
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Web.MastodonAPI.SuggestionView do
  use Pleroma.Web, :view
  alias Pleroma.Web.MastodonAPI.AccountView

  @source_types [:staff, :global, :past_interactions]

  def render("index.json", %{users: users} = opts) do
    Enum.map(users, fn user ->
      opts =
        opts
        |> Map.put(:user, user)
        |> Map.delete(:users)

      render("show.json", opts)
    end)
  end

  def render("show.json", %{source: source, user: _user} = opts) when source in @source_types do
    %{
      source: source,
      account: AccountView.render("show.json", opts)
    }
  end
end