Fixed incorrect usage of "relations" as a short form of "relationships".
This commit is contained in:
parent
7438833685
commit
e743c22329
7 changed files with 29 additions and 25 deletions
|
@ -2442,7 +2442,7 @@
|
|||
%{
|
||||
key: :relations_actions,
|
||||
type: [:tuple, {:list, :tuple}],
|
||||
description: "For actions on relations with all users (follow, unfollow)",
|
||||
description: "For actions on relationships with all users (follow, unfollow)",
|
||||
suggestions: [{1000, 10}, [{10_000, 10}, {10_000, 50}]]
|
||||
},
|
||||
%{
|
||||
|
|
|
@ -39,11 +39,11 @@ def changeset(%Notification{} = notification, attrs) do
|
|||
end
|
||||
|
||||
defp for_user_query_ap_id_opts(user, opts) do
|
||||
ap_id_relations =
|
||||
ap_id_relationships =
|
||||
[:block] ++
|
||||
if opts[@include_muted_option], do: [], else: [:notification_mute]
|
||||
|
||||
preloaded_ap_ids = User.outgoing_relations_ap_ids(user, ap_id_relations)
|
||||
preloaded_ap_ids = User.outgoing_relationships_ap_ids(user, ap_id_relationships)
|
||||
|
||||
exclude_blocked_opts = Map.merge(%{blocked_users_ap_ids: preloaded_ap_ids[:block]}, opts)
|
||||
|
||||
|
@ -370,7 +370,7 @@ def exclude_relation_restricting_ap_ids(ap_ids, %Activity{} = activity) do
|
|||
relation_restricted_ap_ids =
|
||||
activity
|
||||
|> Activity.user_actor()
|
||||
|> User.incoming_relations_ungrouped_ap_ids([
|
||||
|> User.incoming_relationships_ungrouped_ap_ids([
|
||||
:block,
|
||||
:notification_mute
|
||||
])
|
||||
|
|
|
@ -1222,15 +1222,15 @@ def subscribed_to?(%User{} = user, %{ap_id: ap_id}) do
|
|||
end
|
||||
|
||||
@doc """
|
||||
Returns map of outgoing (blocked, muted etc.) relations' user AP IDs by relation type.
|
||||
E.g. `outgoing_relations_ap_ids(user, [:block])` -> `%{block: ["https://some.site/users/userapid"]}`
|
||||
Returns map of outgoing (blocked, muted etc.) relationships' user AP IDs by relation type.
|
||||
E.g. `outgoing_relationships_ap_ids(user, [:block])` -> `%{block: ["https://some.site/users/userapid"]}`
|
||||
"""
|
||||
@spec outgoing_relations_ap_ids(User.t(), list(atom())) :: %{atom() => list(String.t())}
|
||||
def outgoing_relations_ap_ids(_user, []), do: %{}
|
||||
@spec outgoing_relationships_ap_ids(User.t(), list(atom())) :: %{atom() => list(String.t())}
|
||||
def outgoing_relationships_ap_ids(_user, []), do: %{}
|
||||
|
||||
def outgoing_relations_ap_ids(nil, _relationship_types), do: %{}
|
||||
def outgoing_relationships_ap_ids(nil, _relationship_types), do: %{}
|
||||
|
||||
def outgoing_relations_ap_ids(%User{} = user, relationship_types)
|
||||
def outgoing_relationships_ap_ids(%User{} = user, relationship_types)
|
||||
when is_list(relationship_types) do
|
||||
db_result =
|
||||
user
|
||||
|
@ -1249,13 +1249,13 @@ def outgoing_relations_ap_ids(%User{} = user, relationship_types)
|
|||
)
|
||||
end
|
||||
|
||||
def incoming_relations_ungrouped_ap_ids(user, relationship_types, ap_ids \\ nil)
|
||||
def incoming_relationships_ungrouped_ap_ids(user, relationship_types, ap_ids \\ nil)
|
||||
|
||||
def incoming_relations_ungrouped_ap_ids(_user, [], _ap_ids), do: []
|
||||
def incoming_relationships_ungrouped_ap_ids(_user, [], _ap_ids), do: []
|
||||
|
||||
def incoming_relations_ungrouped_ap_ids(nil, _relationship_types, _ap_ids), do: []
|
||||
def incoming_relationships_ungrouped_ap_ids(nil, _relationship_types, _ap_ids), do: []
|
||||
|
||||
def incoming_relations_ungrouped_ap_ids(%User{} = user, relationship_types, ap_ids)
|
||||
def incoming_relationships_ungrouped_ap_ids(%User{} = user, relationship_types, ap_ids)
|
||||
when is_list(relationship_types) do
|
||||
user
|
||||
|> assoc(:incoming_relationships)
|
||||
|
|
|
@ -1230,17 +1230,17 @@ defp maybe_order(query, _), do: query
|
|||
|
||||
defp fetch_activities_query_ap_ids_ops(opts) do
|
||||
source_user = opts["muting_user"]
|
||||
ap_id_relations = if source_user, do: [:mute, :reblog_mute], else: []
|
||||
ap_id_relationships = if source_user, do: [:mute, :reblog_mute], else: []
|
||||
|
||||
ap_id_relations =
|
||||
ap_id_relations ++
|
||||
ap_id_relationships =
|
||||
ap_id_relationships ++
|
||||
if opts["blocking_user"] && opts["blocking_user"] == source_user do
|
||||
[:block]
|
||||
else
|
||||
[]
|
||||
end
|
||||
|
||||
preloaded_ap_ids = User.outgoing_relations_ap_ids(source_user, ap_id_relations)
|
||||
preloaded_ap_ids = User.outgoing_relationships_ap_ids(source_user, ap_id_relationships)
|
||||
|
||||
restrict_blocked_opts = Map.merge(%{"blocked_users_ap_ids" => preloaded_ap_ids[:block]}, opts)
|
||||
restrict_muted_opts = Map.merge(%{"muted_users_ap_ids" => preloaded_ap_ids[:mute]}, opts)
|
||||
|
|
|
@ -63,11 +63,15 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|
|||
when action != :create
|
||||
)
|
||||
|
||||
@relations [:follow, :unfollow]
|
||||
@relationship_actions [:follow, :unfollow]
|
||||
@needs_account ~W(followers following lists follow unfollow mute unmute block unblock)a
|
||||
|
||||
plug(RateLimiter, [name: :relations_id_action, params: ["id", "uri"]] when action in @relations)
|
||||
plug(RateLimiter, [name: :relations_actions] when action in @relations)
|
||||
plug(
|
||||
RateLimiter,
|
||||
[name: :relation_id_action, params: ["id", "uri"]] when action in @relationship_actions
|
||||
)
|
||||
|
||||
plug(RateLimiter, [name: :relations_actions] when action in @relationship_actions)
|
||||
plug(RateLimiter, [name: :app_account_creation] when action == :create)
|
||||
plug(:assign_account_by_id when action in @needs_account)
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ defp do_stream(%{topic: topic, item: item}) do
|
|||
|
||||
defp should_send?(%User{} = user, %Activity{} = item) do
|
||||
%{block: blocked_ap_ids, mute: muted_ap_ids, reblog_mute: reblog_muted_ap_ids} =
|
||||
User.outgoing_relations_ap_ids(user, [:block, :mute, :reblog_mute])
|
||||
User.outgoing_relationships_ap_ids(user, [:block, :mute, :reblog_mute])
|
||||
|
||||
recipient_blocks = MapSet.new(blocked_ap_ids ++ muted_ap_ids)
|
||||
recipients = MapSet.new(item.recipients)
|
||||
|
|
|
@ -86,7 +86,7 @@ test "returns invisible actor" do
|
|||
{:ok, user: insert(:user)}
|
||||
end
|
||||
|
||||
test "outgoing_relations_ap_ids/1", %{user: user} do
|
||||
test "outgoing_relationships_ap_ids/1", %{user: user} do
|
||||
rel_types = [:block, :mute, :notification_mute, :reblog_mute, :inverse_subscription]
|
||||
|
||||
ap_ids_by_rel =
|
||||
|
@ -124,10 +124,10 @@ test "outgoing_relations_ap_ids/1", %{user: user} do
|
|||
assert ap_ids_by_rel[:inverse_subscription] ==
|
||||
Enum.sort(Enum.map(User.subscriber_users(user), & &1.ap_id))
|
||||
|
||||
outgoing_relations_ap_ids = User.outgoing_relations_ap_ids(user, rel_types)
|
||||
outgoing_relationships_ap_ids = User.outgoing_relationships_ap_ids(user, rel_types)
|
||||
|
||||
assert ap_ids_by_rel ==
|
||||
Enum.into(outgoing_relations_ap_ids, %{}, fn {k, v} -> {k, Enum.sort(v)} end)
|
||||
Enum.into(outgoing_relationships_ap_ids, %{}, fn {k, v} -> {k, Enum.sort(v)} end)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue