Fixes outbox privacy

This commit is contained in:
Mouse Reeve 2020-12-30 12:41:19 -08:00
parent 88d8b6e577
commit babc604397
3 changed files with 19 additions and 1 deletions

View file

@ -111,6 +111,7 @@ class User(OrderedCollectionPageMixin, AbstractUser):
queryset = Status.objects.filter(
user=self,
deleted=False,
privacy__in=['public', 'unlisted'],
).select_subclasses().order_by('-published_date')
return self.to_ordered_collection(queryset, \
remote_id=self.outbox, **kwargs)

View file

@ -27,7 +27,6 @@ def outbox(request, username):
''' outbox for the requested user '''
user = get_object_or_404(models.User, localname=username)
# collection overview
return JsonResponse(
user.to_outbox(**request.GET),
encoder=activitypub.ActivityEncoder

View file

@ -69,6 +69,24 @@ class Outgoing(TestCase):
result = outgoing.outbox(request, 'rat')
self.assertEqual(result.status_code, 405)
def test_outbox_privacy(self):
''' don't show dms et cetera in outbox '''
models.Status.objects.create(
content='PRIVATE!!', user=self.local_user, privacy='direct')
models.Status.objects.create(
content='bffs ONLY', user=self.local_user, privacy='followers')
models.Status.objects.create(
content='unlisted status', user=self.local_user, privacy='unlisted')
models.Status.objects.create(
content='look at this', user=self.local_user, privacy='public')
request = self.factory.get('')
result = outgoing.outbox(request, 'mouse')
self.assertIsInstance(result, JsonResponse)
data = json.loads(result.content)
self.assertEqual(data['type'], 'OrderedCollection')
self.assertEqual(data['totalItems'], 2)
def test_handle_follow(self):
''' send a follow request '''