fix(backend): hide non-public replies to comments in event comment threads

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2024-01-05 18:15:08 +01:00
parent c9a1c35aa7
commit 10c4038b85
2 changed files with 9 additions and 2 deletions

View File

@@ -85,6 +85,13 @@ defmodule Mobilizon.Discussions do
|> select([c, r], %{c | total_replies: count(r.id)})
end
# Replies are only used on event comments, so we always use public visibily here
def query(Comment, %{replies: true}) do
Comment
|> where([c], c.visibility in ^@public_visibility)
|> order_by([c], asc: :is_announcement, asc: :published_at)
end
def query(Comment, _) do
order_by(Comment, [c], asc: :is_announcement, asc: :published_at)
end