1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.PleromaAPI.Chat.MessageReferenceView do
9 alias Pleroma.Web.CommonAPI.Utils
10 alias Pleroma.Web.MastodonAPI.StatusView
15 chat_message_reference: %{
17 object: %{data: chat_message} = object,
24 id: id |> to_string(),
25 content: chat_message["content"],
26 chat_id: chat_id |> to_string(),
27 account_id: User.get_cached_by_ap_id(chat_message["actor"]).id,
28 created_at: Utils.to_masto_date(chat_message["published"]),
29 emojis: StatusView.build_emojis(chat_message["emoji"]),
31 chat_message["attachment"] &&
32 StatusView.render("attachment.json", attachment: chat_message["attachment"]),
37 Pleroma.Web.RichMedia.Helpers.fetch_data_for_object(object)
42 def render("index.json", opts) do
44 opts[:chat_message_references],
47 Map.put(opts, :as, :chat_message_reference)