aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2018-05-25 03:16:02 +0000
committerWilliam Pitcock <nenolod@dereferenced.org>2018-05-25 03:18:35 +0000
commit1d88abf2d4834a6dac95c655b9d27cf50377010a (patch)
tree902d07709643460dd67e08ffd8368b445df29765 /lib
parent8d2ee70da18bf057041260ca311127daae9a6f09 (diff)
downloadpleroma-1d88abf2d4834a6dac95c655b9d27cf50377010a.tar.gz
user: do not allow refollowing somebody who has blocked a user
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/user.ex35
1 files changed, 20 insertions, 15 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index 690cc7cf3..508f14584 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -170,25 +170,30 @@ defmodule Pleroma.User do
def follow(%User{} = follower, %User{info: info} = followed) do
ap_followers = followed.follower_address
- if following?(follower, followed) or info["deactivated"] do
- {:error, "Could not follow user: #{followed.nickname} is already on your list."}
- else
- if !followed.local && follower.local && !ap_enabled?(followed) do
- Websub.subscribe(follower, followed)
- end
+ cond do
+ following?(follower, followed) or info["deactivated"] ->
+ {:error, "Could not follow user: #{followed.nickname} is already on your list."}
- following =
- [ap_followers | follower.following]
- |> Enum.uniq()
+ blocks?(followed, follower) ->
+ {:error, "Could not follow user: #{followed.nickname} blocked you."}
- follower =
- follower
- |> follow_changeset(%{following: following})
- |> update_and_set_cache
+ true ->
+ if !followed.local && follower.local && !ap_enabled?(followed) do
+ Websub.subscribe(follower, followed)
+ end
+
+ following =
+ [ap_followers | follower.following]
+ |> Enum.uniq()
- {:ok, _} = update_follower_count(followed)
+ follower =
+ follower
+ |> follow_changeset(%{following: following})
+ |> update_and_set_cache
- follower
+ {:ok, _} = update_follower_count(followed)
+
+ follower
end
end