twitter api: utils: rework do_remote_follow() to use CommonAPI
authorAriadne Conill <ariadne@dereferenced.org>
Mon, 29 Jul 2019 20:00:57 +0000 (20:00 +0000)
committerAriadne Conill <ariadne@dereferenced.org>
Mon, 29 Jul 2019 20:00:57 +0000 (20:00 +0000)
Closes #1138

lib/pleroma/web/twitter_api/controllers/util_controller.ex

index 39bc6147cebfa896a55c1dfa2b662c7960cdf062..5c73a615dd38d8a7b429c4ab1421566fecebbfa3 100644 (file)
@@ -15,7 +15,6 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
   alias Pleroma.Plugs.AuthenticationPlug
   alias Pleroma.User
   alias Pleroma.Web
-  alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.CommonAPI
   alias Pleroma.Web.WebFinger
 
@@ -100,8 +99,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
     with %User{} = user <- User.get_cached_by_nickname(username),
          true <- AuthenticationPlug.checkpw(password, user.password_hash),
          %User{} = _followed <- User.get_cached_by_id(id),
-         {:ok, follower} <- User.follow(user, followee),
-         {:ok, _activity} <- ActivityPub.follow(follower, followee) do
+         {:ok, _follower, _followee, _activity} <- CommonAPI.follow(user, followee) do
       conn
       |> render("followed.html", %{error: false})
     else
@@ -122,8 +120,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
 
   def do_remote_follow(%{assigns: %{user: user}} = conn, %{"user" => %{"id" => id}}) do
     with %User{} = followee <- User.get_cached_by_id(id),
-         {:ok, follower} <- User.follow(user, followee),
-         {:ok, _activity} <- ActivityPub.follow(follower, followee) do
+         {:ok, _follower, _followee, _activity} <- CommonAPI.follow(user, followee) do
       conn
       |> render("followed.html", %{error: false})
     else