aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2018-05-25 09:31:42 +0000
committerWilliam Pitcock <nenolod@dereferenced.org>2018-05-25 09:40:10 +0000
commite80d91c64a53a9d64e48a528f40987c5b36f2ca5 (patch)
treed9fa882e7cd7a2b233c9d0cd4111df9a63222bfb /lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
parentc89b90222c50dcb6f08e8987709dd2bac961f1cb (diff)
downloadpleroma-e80d91c64a53a9d64e48a528f40987c5b36f2ca5.tar.gz
introduce User.maybe_direct_follow() and use it where we used to call User.follow()
Diffstat (limited to 'lib/pleroma/web/mastodon_api/mastodon_api_controller.ex')
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index d50d2d9b5..e12d3fb5b 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -429,6 +429,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
def follow(%{assigns: %{user: follower}} = conn, %{"id" => id}) do
with %User{} = followed <- Repo.get(User, id),
+ {:ok, follower} <- User.maybe_direct_follow(follower, followed),
{:ok, _activity} <- ActivityPub.follow(follower, followed) do
render(conn, AccountView, "relationship.json", %{user: follower, target: followed})
else
@@ -441,6 +442,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
def follow(%{assigns: %{user: follower}} = conn, %{"uri" => uri}) do
with %User{} = followed <- Repo.get_by(User, nickname: uri),
+ {:ok, follower} <- User.maybe_direct_follow(follower, followed),
{:ok, _activity} <- ActivityPub.follow(follower, followed) do
render(conn, AccountView, "account.json", %{user: followed})
else