From 3d94eddcfc3cd50ebc4d265a6708b2564d334cdd Mon Sep 17 00:00:00 2001 From: Eliot Berriot Date: Thu, 7 Mar 2019 12:09:45 +0100 Subject: [PATCH] Fix #743: Do not send notification when rejecting a follow on a local library --- api/funkwhale_api/federation/api_views.py | 3 ++- api/tests/federation/test_api_views.py | 9 ++++++--- changes/changelog.d/743.bugfig | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 changes/changelog.d/743.bugfig diff --git a/api/funkwhale_api/federation/api_views.py b/api/funkwhale_api/federation/api_views.py index 2c7e26582..549bac917 100644 --- a/api/funkwhale_api/federation/api_views.py +++ b/api/funkwhale_api/federation/api_views.py @@ -25,7 +25,8 @@ from . import utils def update_follow(follow, approved): follow.approved = approved follow.save(update_fields=["approved"]) - routes.outbox.dispatch({"type": "Accept"}, context={"follow": follow}) + if approved: + routes.outbox.dispatch({"type": "Accept"}, context={"follow": follow}) class LibraryFollowViewSet( diff --git a/api/tests/federation/test_api_views.py b/api/tests/federation/test_api_views.py index feb2ea246..75579d39a 100644 --- a/api/tests/federation/test_api_views.py +++ b/api/tests/federation/test_api_views.py @@ -123,9 +123,12 @@ def test_user_can_accept_or_reject_own_follows( assert follow.approved is expected - mocked_dispatch.assert_called_once_with( - {"type": "Accept"}, context={"follow": follow} - ) + if action == "accept": + mocked_dispatch.assert_called_once_with( + {"type": "Accept"}, context={"follow": follow} + ) + if action == "reject": + mocked_dispatch.assert_not_called() def test_user_can_list_inbox_items(factories, logged_in_api_client): diff --git a/changes/changelog.d/743.bugfig b/changes/changelog.d/743.bugfig new file mode 100644 index 000000000..5a3ebea0c --- /dev/null +++ b/changes/changelog.d/743.bugfig @@ -0,0 +1 @@ +Do not send notification when rejecting a follow on a local library (#743)