Merge remote-tracking branch 'remotes/origin/develop' into automatic-authentication...
authorIvan Tashkinov <ivantashkinov@gmail.com>
Wed, 22 Apr 2020 15:51:59 +0000 (18:51 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Wed, 22 Apr 2020 15:51:59 +0000 (18:51 +0300)
# Conflicts:
# lib/pleroma/web/mastodon_api/controllers/account_controller.ex

1  2 
lib/pleroma/web/mastodon_api/controllers/account_controller.ex
lib/pleroma/web/twitter_api/controllers/util_controller.ex

index e501b35559e642affffebc95bd95d471f2e6648a,5a92cebd806880d26d97e2c2e851c7cbbfb1c039..e3465e65934748982dd168a6f6e003fa9ffc830f
@@@ -362,14 -356,15 +362,15 @@@ defmodule Pleroma.Web.MastodonAPI.Accou
    end
  
    @doc "POST /api/v1/follows"
-   def follow_by_uri(%{assigns: %{user: follower}} = conn, %{"uri" => uri}) do
-     with {_, %User{} = followed} <- {:followed, User.get_cached_by_nickname(uri)},
-          {_, true} <- {:followed, follower.id != followed.id},
-          {:ok, follower, followed, _} <- CommonAPI.follow(follower, followed) do
-       render(conn, "show.json", user: followed, for: follower)
-     else
-       {:followed, _} -> {:error, :not_found}
-       {:error, message} -> json_response(conn, :forbidden, %{error: message})
 -  def follows(conn, %{"uri" => uri}) do
++  def follow_by_uri(conn, %{"uri" => uri}) do
+     case User.get_cached_by_nickname(uri) do
+       %User{} = user ->
+         conn
+         |> assign(:account, user)
+         |> follow(%{})
+       nil ->
+         {:error, :not_found}
      end
    end