[#1364] Minor improvements / comments.
Further fixes of incorrect usage of "relations" as a short form of "relationships".
This commit is contained in:
parent
012d428e1f
commit
3fa3d45dbe
@ -95,6 +95,7 @@ defmodule Pleroma.Activity do
|
|||||||
|> preload([activity, object: object], object: object)
|
|> preload([activity, object: object], object: object)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Note: applies to fake activities (ActivityPub.Utils.get_notified_from_object/1 etc.)
|
||||||
def user_actor(%Activity{actor: nil}), do: nil
|
def user_actor(%Activity{actor: nil}), do: nil
|
||||||
|
|
||||||
def user_actor(%Activity{} = activity) do
|
def user_actor(%Activity{} = activity) do
|
||||||
|
@ -322,6 +322,8 @@ defmodule Pleroma.Notification do
|
|||||||
@doc """
|
@doc """
|
||||||
Returns a tuple with 2 elements:
|
Returns a tuple with 2 elements:
|
||||||
{enabled notification receivers, currently disabled receivers (blocking / [thread] muting)}
|
{enabled notification receivers, currently disabled receivers (blocking / [thread] muting)}
|
||||||
|
|
||||||
|
NOTE: might be called for FAKE Activities, see ActivityPub.Utils.get_notified_from_object/1
|
||||||
"""
|
"""
|
||||||
def get_notified_from_activity(activity, local_only \\ true)
|
def get_notified_from_activity(activity, local_only \\ true)
|
||||||
|
|
||||||
@ -338,7 +340,7 @@ defmodule Pleroma.Notification do
|
|||||||
# Since even subscribers and followers can mute / thread-mute, filtering all above AP IDs
|
# Since even subscribers and followers can mute / thread-mute, filtering all above AP IDs
|
||||||
notification_enabled_ap_ids =
|
notification_enabled_ap_ids =
|
||||||
potential_receiver_ap_ids
|
potential_receiver_ap_ids
|
||||||
|> exclude_relation_restricting_ap_ids(activity)
|
|> exclude_relationship_restricted_ap_ids(activity)
|
||||||
|> exclude_thread_muter_ap_ids(activity)
|
|> exclude_thread_muter_ap_ids(activity)
|
||||||
|
|
||||||
potential_receivers =
|
potential_receivers =
|
||||||
@ -355,10 +357,10 @@ defmodule Pleroma.Notification do
|
|||||||
def get_notified_from_activity(_, _local_only), do: {[], []}
|
def get_notified_from_activity(_, _local_only), do: {[], []}
|
||||||
|
|
||||||
@doc "Filters out AP IDs of users basing on their relationships with activity actor user"
|
@doc "Filters out AP IDs of users basing on their relationships with activity actor user"
|
||||||
def exclude_relation_restricting_ap_ids([], _activity), do: []
|
def exclude_relationship_restricted_ap_ids([], _activity), do: []
|
||||||
|
|
||||||
def exclude_relation_restricting_ap_ids(ap_ids, %Activity{} = activity) do
|
def exclude_relationship_restricted_ap_ids(ap_ids, %Activity{} = activity) do
|
||||||
relation_restricted_ap_ids =
|
relationship_restricted_ap_ids =
|
||||||
activity
|
activity
|
||||||
|> Activity.user_actor()
|
|> Activity.user_actor()
|
||||||
|> User.incoming_relationships_ungrouped_ap_ids([
|
|> User.incoming_relationships_ungrouped_ap_ids([
|
||||||
@ -366,7 +368,7 @@ defmodule Pleroma.Notification do
|
|||||||
:notification_mute
|
:notification_mute
|
||||||
])
|
])
|
||||||
|
|
||||||
Enum.uniq(ap_ids) -- relation_restricted_ap_ids
|
Enum.uniq(ap_ids) -- relationship_restricted_ap_ids
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc "Filters out AP IDs of users who mute activity thread"
|
@doc "Filters out AP IDs of users who mute activity thread"
|
||||||
|
@ -41,15 +41,16 @@ defmodule Pleroma.ThreadMute do
|
|||||||
|
|
||||||
def muter_ap_ids(context, ap_ids \\ nil)
|
def muter_ap_ids(context, ap_ids \\ nil)
|
||||||
|
|
||||||
def muter_ap_ids(context, ap_ids) when context not in [nil, ""] do
|
# Note: applies to fake activities (ActivityPub.Utils.get_notified_from_object/1 etc.)
|
||||||
|
def muter_ap_ids(context, _ap_ids) when is_nil(context), do: []
|
||||||
|
|
||||||
|
def muter_ap_ids(context, ap_ids) do
|
||||||
context
|
context
|
||||||
|> muters_query()
|
|> muters_query()
|
||||||
|> maybe_filter_on_ap_id(ap_ids)
|
|> maybe_filter_on_ap_id(ap_ids)
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
end
|
end
|
||||||
|
|
||||||
def muter_ap_ids(_context, _ap_ids), do: []
|
|
||||||
|
|
||||||
defp maybe_filter_on_ap_id(query, ap_ids) when is_list(ap_ids) do
|
defp maybe_filter_on_ap_id(query, ap_ids) when is_list(ap_ids) do
|
||||||
where(query, [tm, u], u.ap_id in ^ap_ids)
|
where(query, [tm, u], u.ap_id in ^ap_ids)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user