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.StreamerView do
9 alias Pleroma.Conversation.Participation
10 alias Pleroma.Notification
12 alias Pleroma.Web.MastodonAPI.NotificationView
14 def render("update.json", %Activity{} = activity, %User{} = user) do
18 Pleroma.Web.MastodonAPI.StatusView.render(
28 def render("notification.json", %Notification{} = notify, %User{} = user) do
30 event: "notification",
32 NotificationView.render(
34 %{notification: notify, for: user}
41 def render("update.json", %Activity{} = activity) do
45 Pleroma.Web.MastodonAPI.StatusView.render(
54 def render("chat_update.json", %{chat_message_reference: cm_ref}) do
55 # Explicitly giving the cmr for the object here, so we don't accidentally
56 # send a later 'last_message' that was inserted between inserting this and
59 # It also contains the chat with a cache of the correct unread count
60 Logger.debug("Trying to stream out #{inspect(cm_ref)}")
63 Pleroma.Web.PleromaAPI.ChatView.render(
65 %{last_message: cm_ref, chat: cm_ref.chat}
69 event: "pleroma:chat_update",
77 def render("conversation.json", %Participation{} = participation) do
79 event: "conversation",
81 Pleroma.Web.MastodonAPI.ConversationView.render("participation.json", %{
82 participation: participation,
83 for: participation.user