Merge pull request #942 from bookwyrm-social/stop-broadcasting-yourself
Fixes bug that causes recursive broadcasts
This commit is contained in:
commit
880e28bac8
|
@ -359,6 +359,10 @@ class CollectionItemMixin(ActivitypubMixin):
|
||||||
|
|
||||||
activity_serializer = activitypub.CollectionItem
|
activity_serializer = activitypub.CollectionItem
|
||||||
|
|
||||||
|
def broadcast(self, activity, sender, software="bookwyrm"):
|
||||||
|
""" only send book collection updates to other bookwyrm instances """
|
||||||
|
super().broadcast(activity, sender, software=software)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def privacy(self):
|
def privacy(self):
|
||||||
""" inherit the privacy of the list, or direct if pending """
|
""" inherit the privacy of the list, or direct if pending """
|
||||||
|
@ -371,6 +375,9 @@ class CollectionItemMixin(ActivitypubMixin):
|
||||||
def recipients(self):
|
def recipients(self):
|
||||||
""" the owner of the list is a direct recipient """
|
""" the owner of the list is a direct recipient """
|
||||||
collection_field = getattr(self, self.collection_field)
|
collection_field = getattr(self, self.collection_field)
|
||||||
|
if collection_field.user.local:
|
||||||
|
# don't broadcast to yourself
|
||||||
|
return []
|
||||||
return [collection_field.user]
|
return [collection_field.user]
|
||||||
|
|
||||||
def save(self, *args, broadcast=True, **kwargs):
|
def save(self, *args, broadcast=True, **kwargs):
|
||||||
|
|
|
@ -55,7 +55,7 @@ class List(TestCase):
|
||||||
|
|
||||||
self.assertTrue(item.approved)
|
self.assertTrue(item.approved)
|
||||||
self.assertEqual(item.privacy, "unlisted")
|
self.assertEqual(item.privacy, "unlisted")
|
||||||
self.assertEqual(item.recipients, [self.local_user])
|
self.assertEqual(item.recipients, [])
|
||||||
|
|
||||||
def test_list_item_pending(self, _):
|
def test_list_item_pending(self, _):
|
||||||
""" a list entry """
|
""" a list entry """
|
||||||
|
@ -71,4 +71,4 @@ class List(TestCase):
|
||||||
self.assertFalse(item.approved)
|
self.assertFalse(item.approved)
|
||||||
self.assertEqual(item.book_list.privacy, "public")
|
self.assertEqual(item.book_list.privacy, "public")
|
||||||
self.assertEqual(item.privacy, "direct")
|
self.assertEqual(item.privacy, "direct")
|
||||||
self.assertEqual(item.recipients, [self.local_user])
|
self.assertEqual(item.recipients, [])
|
||||||
|
|
Loading…
Reference in New Issue