From: Ivan Tashkinov Date: Wed, 22 Apr 2020 15:51:59 +0000 (+0300) Subject: Merge remote-tracking branch 'remotes/origin/develop' into automatic-authentication... X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=0062116e07446beea13768d122e5bcb19c60dde7;p=akkoma Merge remote-tracking branch 'remotes/origin/develop' into automatic-authentication-and-instance-publicity-checks # Conflicts: # lib/pleroma/web/mastodon_api/controllers/account_controller.ex --- 0062116e07446beea13768d122e5bcb19c60dde7 diff --cc lib/pleroma/web/mastodon_api/controllers/account_controller.ex index e501b3555,5a92cebd8..e3465e659 --- a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex @@@ -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