1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.AdminAPI.ChatView do
10 alias Pleroma.Web.MastodonAPI
11 alias Pleroma.Web.PleromaAPI
13 def render("index.json", %{chats: chats} = opts) do
14 render_many(chats, __MODULE__, "show.json", Map.delete(opts, :chats))
17 def render("show.json", %{chat: %Chat{user_id: user_id}} = opts) do
18 user = User.get_by_id(user_id)
19 sender = MastodonAPI.AccountView.render("show.json", user: user, skip_visibility_check: true)
21 serialized_chat = PleromaAPI.ChatView.render("show.json", opts)
24 |> Map.put(:sender, sender)
25 |> Map.put(:receiver, serialized_chat[:account])
26 |> Map.delete(:account)
29 def render(view, opts), do: PleromaAPI.ChatView.render(view, opts)