aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/streamer.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pleroma/web/streamer.ex')
-rw-r--r--lib/pleroma/web/streamer.ex38
1 files changed, 24 insertions, 14 deletions
diff --git a/lib/pleroma/web/streamer.ex b/lib/pleroma/web/streamer.ex
index 10670e71f..33041ec12 100644
--- a/lib/pleroma/web/streamer.ex
+++ b/lib/pleroma/web/streamer.ex
@@ -3,6 +3,10 @@ defmodule Pleroma.Web.Streamer do
require Logger
alias Pleroma.{User, Notification}
+ def init(args) do
+ {:ok, args}
+ end
+
def start_link do
spawn(fn ->
# 30 seconds
@@ -110,20 +114,26 @@ defmodule Pleroma.Web.Streamer do
def push_to_socket(topics, topic, item) do
Enum.each(topics[topic] || [], fn socket ->
- json =
- %{
- event: "update",
- payload:
- Pleroma.Web.MastodonAPI.StatusView.render(
- "status.json",
- activity: item,
- for: socket.assigns[:user]
- )
- |> Jason.encode!()
- }
- |> Jason.encode!()
-
- send(socket.transport_pid, {:text, json})
+ # Get the current user so we have up-to-date blocks etc.
+ user = User.get_cached_by_ap_id(socket.assigns[:user].ap_id)
+ blocks = user.info["blocks"] || []
+
+ unless item.actor in blocks do
+ json =
+ %{
+ event: "update",
+ payload:
+ Pleroma.Web.MastodonAPI.StatusView.render(
+ "status.json",
+ activity: item,
+ for: user
+ )
+ |> Jason.encode!()
+ }
+ |> Jason.encode!()
+
+ send(socket.transport_pid, {:text, json})
+ end
end)
end