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
10 alias Pleroma.Conversation.Participation
11 alias Pleroma.Notification
13 alias Pleroma.Web.MastodonAPI.NotificationView
15 def render("chat_update.json", object, user, recipients) do
16 chat = Chat.get(user.id, hd(recipients -- [user.ap_id]))
19 Pleroma.Web.PleromaAPI.ChatView.render(
21 %{message: object, chat: chat}
25 event: "pleroma:chat_update",
33 def render("update.json", %Activity{} = activity, %User{} = user) do
37 Pleroma.Web.MastodonAPI.StatusView.render(
47 def render("notification.json", %Notification{} = notify, %User{} = user) do
49 event: "notification",
51 NotificationView.render(
53 %{notification: notify, for: user}
60 def render("update.json", %Activity{} = activity) do
64 Pleroma.Web.MastodonAPI.StatusView.render(
73 def render("conversation.json", %Participation{} = participation) do
75 event: "conversation",
77 Pleroma.Web.MastodonAPI.ConversationView.render("participation.json", %{
78 participation: participation,
79 for: participation.user