mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-14 03:24:04 +00:00
c4439c630f
grep -rl '# Copyright © .* Pleroma' * | xargs sed -i 's;Copyright © .* Pleroma .*;Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>;'
31 lines
955 B
Elixir
31 lines
955 B
Elixir
# Pleroma: A lightweight social networking server
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
defmodule Pleroma.Web.AdminAPI.ChatView do
|
|
use Pleroma.Web, :view
|
|
|
|
alias Pleroma.Chat
|
|
alias Pleroma.User
|
|
alias Pleroma.Web.MastodonAPI
|
|
alias Pleroma.Web.PleromaAPI
|
|
|
|
def render("index.json", %{chats: chats} = opts) do
|
|
render_many(chats, __MODULE__, "show.json", Map.delete(opts, :chats))
|
|
end
|
|
|
|
def render("show.json", %{chat: %Chat{user_id: user_id}} = opts) do
|
|
user = User.get_by_id(user_id)
|
|
sender = MastodonAPI.AccountView.render("show.json", user: user, skip_visibility_check: true)
|
|
|
|
serialized_chat = PleromaAPI.ChatView.render("show.json", opts)
|
|
|
|
serialized_chat
|
|
|> Map.put(:sender, sender)
|
|
|> Map.put(:receiver, serialized_chat[:account])
|
|
|> Map.delete(:account)
|
|
end
|
|
|
|
def render(view, opts), do: PleromaAPI.ChatView.render(view, opts)
|
|
end
|