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
+
def follow(%User{} = follower, %User{info: info} = followed) do
ap_followers = followed.follower_address
def authorize_follow_request(%{assigns: %{user: followed}} = conn, %{"id" => id}) do
with %User{} = follower <- Repo.get(User, id),
- {:ok, follower} <- User.follow(follower, followed),
+ {:ok, follower} <- User.maybe_follow(follower, followed),
%Activity{} = follow_activity <- Utils.fetch_latest_follow(follower, followed),
{:ok, follow_activity} <- Utils.update_follow_state(follow_activity, "accept"),
{:ok, _activity} <-