X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Fviews%2Fstreamer_view.ex;h=a9f14d09ac0de09af00b51946e4bb6a2b192d4aa;hb=11ec9daa5b742f8a1b408497321392e144f45019;hp=b13030fa0a13ba2a78634f4cc7263558b58a0ba4;hpb=c4fbb56984d8f86df948cfd9b0f7c081d688c365;p=akkoma
diff --git a/lib/pleroma/web/views/streamer_view.ex b/lib/pleroma/web/views/streamer_view.ex
index b13030fa0..f455f941e 100644
--- a/lib/pleroma/web/views/streamer_view.ex
+++ b/lib/pleroma/web/views/streamer_view.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.StreamerView do
@@ -11,12 +11,13 @@ defmodule Pleroma.Web.StreamerView do
alias Pleroma.User
alias Pleroma.Web.MastodonAPI.NotificationView
- def render("update.json", %Activity{} = activity, %User{} = user) do
+ def render("update.json", %Activity{} = activity, %User{} = user, topic) do
%{
+ stream: [topic],
event: "update",
payload:
Pleroma.Web.MastodonAPI.StatusView.render(
- "status.json",
+ "show.json",
activity: activity,
for: user
)
@@ -25,8 +26,9 @@ defmodule Pleroma.Web.StreamerView do
|> Jason.encode!()
end
- def render("notification.json", %User{} = user, %Notification{} = notify) do
+ def render("notification.json", %Notification{} = notify, %User{} = user, topic) do
%{
+ stream: [topic],
event: "notification",
payload:
NotificationView.render(
@@ -38,12 +40,13 @@ defmodule Pleroma.Web.StreamerView do
|> Jason.encode!()
end
- def render("update.json", %Activity{} = activity) do
+ def render("update.json", %Activity{} = activity, topic) do
%{
+ stream: [topic],
event: "update",
payload:
Pleroma.Web.MastodonAPI.StatusView.render(
- "status.json",
+ "show.json",
activity: activity
)
|> Jason.encode!()
@@ -51,8 +54,32 @@ defmodule Pleroma.Web.StreamerView do
|> Jason.encode!()
end
- def render("conversation.json", %Participation{} = participation) do
+ def render("follow_relationships_update.json", item, topic) do
+ %{
+ stream: [topic],
+ event: "pleroma:follow_relationships_update",
+ payload:
+ %{
+ state: item.state,
+ follower: %{
+ id: item.follower.id,
+ follower_count: item.follower.follower_count,
+ following_count: item.follower.following_count
+ },
+ following: %{
+ id: item.following.id,
+ follower_count: item.following.follower_count,
+ following_count: item.following.following_count
+ }
+ }
+ |> Jason.encode!()
+ }
+ |> Jason.encode!()
+ end
+
+ def render("conversation.json", %Participation{} = participation, topic) do
%{
+ stream: [topic],
event: "conversation",
payload:
Pleroma.Web.MastodonAPI.ConversationView.render("participation.json", %{