From: Sadposter Date: Tue, 10 Dec 2019 16:54:25 +0000 (+0000) Subject: Merge branch 'develop' into 'domain-block-precedence' X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=8cfaab8f04cae6fcc20a37cdb463ee0c93b71217;p=akkoma Merge branch 'develop' into 'domain-block-precedence' # Conflicts: # lib/pleroma/user.ex --- 8cfaab8f04cae6fcc20a37cdb463ee0c93b71217 diff --cc lib/pleroma/user.ex index 601aa9cf0,6b556e8e1..cebadc8ab --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@@ -1023,21 -1130,20 +1137,21 @@@ defmodule Pleroma.User d @spec muted_notifications?(User.t() | nil, User.t() | map()) :: boolean() def muted_notifications?(nil, _), do: false - def muted_notifications?(user, %{ap_id: ap_id}), - do: Enum.member?(user.muted_notifications, ap_id) + def muted_notifications?(%User{} = user, %User{} = target), + do: UserRelationship.notification_mute_exists?(user, target) + + def blocks?(nil, _), do: false def blocks?(%User{} = user, %User{} = target) do - blocks_user?(user, target) || blocks_domain?(user, target) + blocks_ap_id?(user, target) || + (!User.following?(user, target) && blocks_domain?(user, target)) end - def blocks?(nil, _), do: false - - def blocks_ap_id?(%User{} = user, %User{} = target) do - Enum.member?(user.blocks, target.ap_id) + def blocks_user?(%User{} = user, %User{} = target) do + UserRelationship.block_exists?(user, target) end - def blocks_ap_id?(_, _), do: false + def blocks_user?(_, _), do: false def blocks_domain?(%User{} = user, %User{} = target) do domain_blocks = Pleroma.Web.ActivityPub.MRF.subdomains_regex(user.domain_blocks) diff --cc lib/pleroma/web/activity_pub/activity_pub.ex index 29cc1a17b,6571102a9..c6744e5f2 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@@ -912,14 -946,10 +946,14 @@@ defmodule Pleroma.Web.ActivityPub.Activ defp restrict_muted(query, _), do: query - defp restrict_blocked(query, %{"blocking_user" => %User{} = user}) do - blocks = user.blocks || [] + defp restrict_blocked(query, %{"blocking_user" => %User{} = user} = opts) do + blocked_ap_ids = opts["blocked_users_ap_ids"] || User.blocked_users_ap_ids(user) domain_blocks = user.domain_blocks || [] + following_ap_ids = + user + |> User.get_friends_ap_ids() + query = if has_named_binding?(query, :object), do: query, else: Activity.with_joined_object(query) @@@ -932,24 -962,10 +966,24 @@@ "not (?->>'type' = 'Announce' and ?->'to' \\?| ?)", activity.data, activity.data, - ^blocks + ^blocked_ap_ids ), - where: fragment("not (split_part(?, '/', 3) = ANY(?))", activity.actor, ^domain_blocks), - where: fragment("not (split_part(?->>'actor', '/', 3) = ANY(?))", o.data, ^domain_blocks) + where: + fragment( + "(not (split_part(?, '/', 3) = ANY(?))) or ? = ANY(?)", + activity.actor, + ^domain_blocks, + activity.actor, + ^following_ap_ids + ), + where: + fragment( + "(not (split_part(?->>'actor', '/', 3) = ANY(?))) or (?->>'actor') = ANY(?)", + o.data, + ^domain_blocks, + o.data, + ^following_ap_ids + ) ) end