move configurable module attributes into relevant functions
authorsquidboi <squidboi@waifu.club>
Sat, 23 Jun 2018 21:16:08 +0000 (14:16 -0700)
committersquidboi <squidboi@waifu.club>
Sat, 23 Jun 2018 21:16:08 +0000 (14:16 -0700)
lib/pleroma/user.ex
lib/pleroma/web/activity_pub/activity_pub.ex

index 1fcec479f1cae9fb8a623d5b2ae95698371fa37d..6000e74fc0af03ce90ed0957655354695b4f74ef 100644 (file)
@@ -168,10 +168,10 @@ defmodule Pleroma.User do
     end
   end
 
-  @user_config Application.get_env(:pleroma, :user)
-  @deny_follow_blocked Keyword.get(@user_config, :deny_follow_blocked)
-
   def maybe_direct_follow(%User{} = follower, %User{info: info} = followed) do
+    @user_config Application.get_env(:pleroma, :user)
+    @deny_follow_blocked Keyword.get(@user_config, :deny_follow_blocked)
+
     user_info = user_info(followed)
 
     should_direct_follow =
@@ -209,10 +209,10 @@ defmodule Pleroma.User do
     end
   end
 
-  @user_config Application.get_env(:pleroma, :user)
-  @deny_follow_blocked Keyword.get(@user_config, :deny_follow_blocked)
-
   def follow(%User{} = follower, %User{info: info} = followed) do
+    @user_config Application.get_env(:pleroma, :user)
+    @deny_follow_blocked Keyword.get(@user_config, :deny_follow_blocked)
+
     ap_followers = followed.follower_address
 
     cond do
index b174af7ce1513bbd2f6da97882d36fee5d23a89d..b76edbd8b9f4d2f2eaa30c5a15857657ded48335 100644 (file)
@@ -242,11 +242,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
     end
   end
 
-  @ap_config Application.get_env(:pleroma, :activitypub)
-  @unfollow_blocked Keyword.get(@ap_config, :unfollow_blocked)
-  @outgoing_blocks Keyword.get(@ap_config, :outgoing_blocks)
-
   def block(blocker, blocked, activity_id \\ nil, local \\ true) do
+    @ap_config Application.get_env(:pleroma, :activitypub)
+    @unfollow_blocked Keyword.get(@ap_config, :unfollow_blocked)
+    @outgoing_blocks Keyword.get(@ap_config, :outgoing_blocks)
+
     with true <- @unfollow_blocked do
       follow_activity = fetch_latest_follow(blocker, blocked)