forked from mirrors/bookwyrm
Fixes filters
This commit is contained in:
parent
88a65b0b88
commit
4db5677509
2 changed files with 11 additions and 6 deletions
|
@ -43,6 +43,7 @@ class SuggestedUsers(RedisStore):
|
|||
~Q(id=user.id),
|
||||
~Q(followers=user),
|
||||
~Q(follower_requests=user),
|
||||
bookwyrm_user=True,
|
||||
)
|
||||
|
||||
def get_stores_for_object(self, obj):
|
||||
|
@ -106,9 +107,7 @@ class SuggestedUsers(RedisStore):
|
|||
def get_annotated_users(viewer, *args, **kwargs):
|
||||
"""Users, annotated with things they have in common"""
|
||||
return (
|
||||
models.User.objects.filter(
|
||||
discoverable=True, is_active=True, bookwyrm_user=True, *args, **kwargs
|
||||
)
|
||||
models.User.objects.filter(discoverable=True, is_active=True, *args, **kwargs)
|
||||
.exclude(Q(id__in=viewer.blocks.all()) | Q(blocks=viewer))
|
||||
.annotate(
|
||||
mutuals=Count(
|
||||
|
@ -196,7 +195,7 @@ def update_user(sender, instance, created, update_fields=None, **kwargs):
|
|||
return
|
||||
|
||||
# deleted the user
|
||||
if not instance.is_active:
|
||||
if not created and not instance.is_active:
|
||||
remove_user_task.delay(instance.id)
|
||||
return
|
||||
|
||||
|
|
|
@ -80,7 +80,9 @@ class FederationViews(TestCase):
|
|||
request.user = self.local_user
|
||||
request.user.is_superuser = True
|
||||
|
||||
view(request, server.id)
|
||||
with patch("bookwyrm.suggested_users.bulk_remove_instance_task.delay") as mock:
|
||||
view(request, server.id)
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
|
||||
server.refresh_from_db()
|
||||
self.remote_user.refresh_from_db()
|
||||
|
@ -118,7 +120,11 @@ class FederationViews(TestCase):
|
|||
request.user = self.local_user
|
||||
request.user.is_superuser = True
|
||||
|
||||
views.federation.unblock_server(request, server.id)
|
||||
with patch("bookwyrm.suggested_users.bulk_add_instance_task.delay") as mock:
|
||||
views.federation.unblock_server(request, server.id)
|
||||
self.assertEqual(mock.call_count, 1)
|
||||
self.assertEqual(mock.call_args[0][0], server.id)
|
||||
|
||||
server.refresh_from_db()
|
||||
self.remote_user.refresh_from_db()
|
||||
self.assertEqual(server.status, "federated")
|
||||
|
|
Loading…
Reference in a new issue