logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: 52f7033f7ac82155fc927f4b0a3f4f9e8ae11114
parent b389b85d7760d9c275b2584e0e99bff4f0265222
Author: marcin mikołajczak <git@mkljczk.pl>
Date:   Sun,  4 Aug 2024 16:02:44 +0200

StreamerView: Do not leak follows count if hidden

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>

Diffstat:

Achangelog.d/stream-follow-relationships-count.fix2++
Mlib/pleroma/web/views/streamer_view.ex26+++++++++++++++++++-------
2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/changelog.d/stream-follow-relationships-count.fix b/changelog.d/stream-follow-relationships-count.fix @@ -0,0 +1 @@ +StreamerView: Do not leak follows count if hidden +\ No newline at end of file diff --git a/lib/pleroma/web/views/streamer_view.ex b/lib/pleroma/web/views/streamer_view.ex @@ -109,7 +109,11 @@ defmodule Pleroma.Web.StreamerView do |> Jason.encode!() end - def render("follow_relationships_update.json", item, topic) do + def render( + "follow_relationships_update.json", + %{follower: follower, following: following} = item, + topic + ) do %{ stream: render("stream.json", %{topic: topic}), event: "pleroma:follow_relationships_update", @@ -117,14 +121,22 @@ defmodule Pleroma.Web.StreamerView do %{ state: item.state, follower: %{ - id: item.follower.id, - follower_count: item.follower.follower_count, - following_count: item.follower.following_count + id: follower.id, + follower_count: follower.follower_count, + following_count: follower.following_count }, following: %{ - id: item.following.id, - follower_count: item.following.follower_count, - following_count: item.following.following_count + id: following.id, + follower_count: + if(!following.hide_followers_count or !following.hide_followers, + do: following.follower_count, + else: 0 + ), + following_count: + if(!following.hide_follows_count or !following.hide_follows, + do: following.following_count, + else: 0 + ) } } |> Jason.encode!()