Fixed incorrect usage of "relations" as a short form of "relationships".
authorIvan Tashkinov <ivantashkinov@gmail.com>
Wed, 25 Mar 2020 06:04:00 +0000 (09:04 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Wed, 25 Mar 2020 06:04:00 +0000 (09:04 +0300)
config/description.exs
lib/pleroma/notification.ex
lib/pleroma/user.ex
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/mastodon_api/controllers/account_controller.ex
lib/pleroma/web/streamer/worker.ex
test/user_test.exs

index 732c767344387445d03304b19893bd15ec47a859..68fa8b03bf0dba9476f59398a85cf9bd0d979412 100644 (file)
@@ -2442,7 +2442,7 @@ config :pleroma, :config_description, [
       %{
         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}]]
       },
       %{
index 104368fd172a8c5195ad5df6f302962170e8e85f..bc691dce37d01db11533eb010513b6857a356768 100644 (file)
@@ -39,11 +39,11 @@ defmodule Pleroma.Notification 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 @@ defmodule Pleroma.Notification do
     relation_restricted_ap_ids =
       activity
       |> Activity.user_actor()
-      |> User.incoming_relations_ungrouped_ap_ids([
+      |> User.incoming_relationships_ungrouped_ap_ids([
         :block,
         :notification_mute
       ])
index 05efc74d4842a515949243bfaa6b89e91db908b6..4919c8e5842a68b3bf59d660f092992e2b542f24 100644 (file)
@@ -1222,15 +1222,15 @@ defmodule Pleroma.User 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 @@ defmodule Pleroma.User do
     )
   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)
index d9f74b6a4928004f074025369bd26183aa517253..60e74758f5f953c424a0f4e9c00bec9c404b6d9f 100644 (file)
@@ -1230,17 +1230,17 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
 
   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)
index 88c997b9f75e2510262c6a945f3d9de514a7c10c..9d83a9fc1f72dc6d73f3b29972cdc700ed8b4cd7 100644 (file)
@@ -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)
 
index 29f992a678cb6014552725a18b89e117b7ea9bc4..abfed21c8aa51eee4458848fcba33fdf4cd8e177 100644 (file)
@@ -130,7 +130,7 @@ defmodule Pleroma.Web.Streamer.Worker 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)
index b07fed42bac84b2eb9b0830887e0ad4f74893f4c..f3d044a803e147992b314c52f4ab1fd07651ccbe 100644 (file)
@@ -86,7 +86,7 @@ defmodule Pleroma.UserTest 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 @@ defmodule Pleroma.UserTest 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