Add ability to follow hashtags (#336)
[akkoma] / lib / pleroma / web / mastodon_api / views / suggestion_view.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.MastodonAPI.SuggestionView do
6 use Pleroma.Web, :view
7 alias Pleroma.Web.MastodonAPI.AccountView
8
9 @source_types [:staff, :global, :past_interactions]
10
11 def render("index.json", %{users: users} = opts) do
12 Enum.map(users, fn user ->
13 opts =
14 opts
15 |> Map.put(:user, user)
16 |> Map.delete(:users)
17
18 render("show.json", opts)
19 end)
20 end
21
22 def render("show.json", %{source: source, user: _user} = opts) when source in @source_types do
23 %{
24 source: source,
25 account: AccountView.render("show.json", opts)
26 }
27 end
28 end