diff options
author | rinpatch <rinpatch@sdf.org> | 2019-10-21 16:44:17 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2019-10-21 16:44:17 +0000 |
commit | 6712b6e4de304eac09955689bcefbbe21d7fc1a5 (patch) | |
tree | 19e27df441249bb4bdcc3ab4c32af70058ef988a /lib | |
parent | ce750dbab5de905af1e0ba6ba6a5a08b41600ac1 (diff) | |
parent | 2dbee29cf5a1a17438e8bc3d2586717da64e20ff (diff) | |
download | pleroma-6712b6e4de304eac09955689bcefbbe21d7fc1a5.tar.gz |
Merge branch 'fix/notifs-exclude-blocked-from-with-muted' into 'develop'
Do not include notifications from blocked users when with_muted is set
See merge request pleroma/pleroma!1869
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/notification.ex | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/pleroma/notification.ex b/lib/pleroma/notification.ex index d145f8d5b..e5da1492b 100644 --- a/lib/pleroma/notification.ex +++ b/lib/pleroma/notification.ex @@ -55,9 +55,19 @@ defmodule Pleroma.Notification do ) |> preload([n, a, o], activity: {a, object: o}) |> exclude_muted(user, opts) + |> exclude_blocked(user) |> exclude_visibility(opts) end + defp exclude_blocked(query, user) do + query + |> where([n, a], a.actor not in ^user.info.blocks) + |> where( + [n, a], + fragment("substring(? from '.*://([^/]*)')", a.actor) not in ^user.info.domain_blocks + ) + end + defp exclude_muted(query, _, %{with_muted: true}) do query end @@ -65,11 +75,6 @@ defmodule Pleroma.Notification do defp exclude_muted(query, user, _opts) do query |> where([n, a], a.actor not in ^user.info.muted_notifications) - |> where([n, a], a.actor not in ^user.info.blocks) - |> where( - [n, a], - fragment("substring(? from '.*://([^/]*)')", a.actor) not in ^user.info.domain_blocks - ) |> join(:left, [n, a], tm in Pleroma.ThreadMute, on: tm.user_id == ^user.id and tm.context == fragment("?->>'context'", a.data) ) |