User: Remove superfluous `maybe_follow`.
authorlain <lain@soykaf.club>
Wed, 5 Jun 2019 12:24:31 +0000 (14:24 +0200)
committerlain <lain@soykaf.club>
Wed, 5 Jun 2019 12:24:31 +0000 (14:24 +0200)
lib/pleroma/user.ex
lib/pleroma/web/activity_pub/transmogrifier.ex
lib/pleroma/web/common_api/common_api.ex
test/user_test.exs

index d873d7623e8b5d5cf7a57306303144d8a6cbc6e5..3d8fa0edb88a25a9e844bcada4ded53aca76a53e 100644 (file)
@@ -324,14 +324,6 @@ defmodule Pleroma.User do
     end
   end
 
-  def maybe_follow(%User{} = follower, %User{info: _info} = followed) do
-    if not following?(follower, followed) do
-      follow(follower, followed)
-    else
-      {:ok, follower}
-    end
-  end
-
   @doc "A mass follow for local users. Respects blocks in both directions but does not create activities."
   @spec follow_all(User.t(), list(User.t())) :: {atom(), User.t()}
   def follow_all(follower, followeds) do
index 8aa44ec09199fb917824c12629eb7ec3ef84b9e6..e8df112b9c4d78fab98726f1b73d23ef7c7372f8 100644 (file)
@@ -509,19 +509,14 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
          {:ok, follow_activity} <- get_follow_activity(follow_object, followed),
          {:ok, follow_activity} <- Utils.update_follow_state(follow_activity, "accept"),
          %User{local: true} = follower <- User.get_cached_by_ap_id(follow_activity.data["actor"]),
-         {:ok, activity} <-
-           ActivityPub.accept(%{
-             to: follow_activity.data["to"],
-             type: "Accept",
-             actor: followed,
-             object: follow_activity.data["id"],
-             local: false
-           }) do
-      if not User.following?(follower, followed) do
-        {:ok, _follower} = User.follow(follower, followed)
-      end
-
-      {:ok, activity}
+         {:ok, _follower} = User.follow(follower, followed) do
+      ActivityPub.accept(%{
+        to: follow_activity.data["to"],
+        type: "Accept",
+        actor: followed,
+        object: follow_activity.data["id"],
+        local: false
+      })
     else
       _e -> :error
     end
index 2b3ae3de50ba2a3d50b9669b3f8f6992060298d5..71e166128d7151b622e164c58b5835bc3c124235 100644 (file)
@@ -35,7 +35,7 @@ defmodule Pleroma.Web.CommonAPI do
   end
 
   def accept_follow_request(follower, followed) do
-    with {:ok, follower} <- User.maybe_follow(follower, followed),
+    with {:ok, follower} <- User.follow(follower, followed),
          %Activity{} = follow_activity <- Utils.fetch_latest_follow(follower, followed),
          {:ok, follow_activity} <- Utils.update_follow_state(follow_activity, "accept"),
          {:ok, _activity} <-
index d7473ef4323413ca223c8848735ea8dce9f69dca..466ddbf74d2726e2aa1827cafe8d756ac8078f3f 100644 (file)
@@ -75,7 +75,7 @@ defmodule Pleroma.UserTest do
     Pleroma.Web.TwitterAPI.TwitterAPI.follow(pending_follower, %{"user_id" => locked.id})
     Pleroma.Web.TwitterAPI.TwitterAPI.follow(pending_follower, %{"user_id" => locked.id})
     Pleroma.Web.TwitterAPI.TwitterAPI.follow(accepted_follower, %{"user_id" => locked.id})
-    User.maybe_follow(accepted_follower, locked)
+    User.follow(accepted_follower, locked)
 
     assert {:ok, [activity]} = User.get_follow_requests(locked)
     assert activity