aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaniini <ariadne@dereferenced.org>2019-07-14 19:25:03 +0000
committerkaniini <ariadne@dereferenced.org>2019-07-14 19:25:03 +0000
commit4b78622bbaf743d540022b8aeec41405ca0cad8f (patch)
tree58d63391301df259173057ce8ddf81ed52014fef
parent509d8058d99d7455155b6e7fad83fed28f2ae02d (diff)
parentdce8ebc9eabac1a597491a0edc5c145285c55671 (diff)
downloadpleroma-4b78622bbaf743d540022b8aeec41405ca0cad8f.tar.gz
Merge branch 'feature/unsubscribe-on-unfollow' into 'develop'
Unfollow should also unsubscribe Closes #1086 See merge request pleroma/pleroma!1419
-rw-r--r--CHANGELOG.md1
-rw-r--r--lib/pleroma/web/common_api/common_api.ex3
-rw-r--r--test/web/common_api/common_api_test.exs14
3 files changed, 17 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e7d7e0ef5..7fc8db31c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Configuration: Filter.AnonymizeFilename added ability to retain file extension with custom text
- Federation: Return 403 errors when trying to request pages from a user's follower/following collections if they have `hide_followers`/`hide_follows` set
- NodeInfo: Return `skipThreadContainment` in `metadata` for the `skip_thread_containment` option
+- Mastodon API: Unsubscribe followers when they unfollow a user
### Fixed
- Not being able to pin unlisted posts
diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex
index f1450b113..949baa3b0 100644
--- a/lib/pleroma/web/common_api/common_api.ex
+++ b/lib/pleroma/web/common_api/common_api.ex
@@ -31,7 +31,8 @@ defmodule Pleroma.Web.CommonAPI do
def unfollow(follower, unfollowed) do
with {:ok, follower, _follow_activity} <- User.unfollow(follower, unfollowed),
- {:ok, _activity} <- ActivityPub.unfollow(follower, unfollowed) do
+ {:ok, _activity} <- ActivityPub.unfollow(follower, unfollowed),
+ {:ok, _unfollowed} <- User.unsubscribe(follower, unfollowed) do
{:ok, follower}
end
end
diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs
index 958c931c4..b59b6cbf6 100644
--- a/test/web/common_api/common_api_test.exs
+++ b/test/web/common_api/common_api_test.exs
@@ -346,6 +346,20 @@ defmodule Pleroma.Web.CommonAPITest do
end
end
+ describe "unfollow/2" do
+ test "also unsubscribes a user" do
+ [follower, followed] = insert_pair(:user)
+ {:ok, follower, followed, _} = CommonAPI.follow(follower, followed)
+ {:ok, followed} = User.subscribe(follower, followed)
+
+ assert User.subscribed_to?(follower, followed)
+
+ {:ok, follower} = CommonAPI.unfollow(follower, followed)
+
+ refute User.subscribed_to?(follower, followed)
+ end
+ end
+
describe "accept_follow_request/2" do
test "after acceptance, it sets all existing pending follow request states to 'accept'" do
user = insert(:user, info: %{locked: true})