From ff721896c08712c237ee44a9a2131ec6c45653d8 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 6 Feb 2021 12:06:45 -0800 Subject: [PATCH] Fixes call to mention_users --- bookwyrm/models/activitypub_mixin.py | 5 +++-- bookwyrm/tests/models/test_activitypub_mixin.py | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bookwyrm/models/activitypub_mixin.py b/bookwyrm/models/activitypub_mixin.py index 55e4971ec..de440e425 100644 --- a/bookwyrm/models/activitypub_mixin.py +++ b/bookwyrm/models/activitypub_mixin.py @@ -121,10 +121,11 @@ class ActivitypubMixin: # or maybe the thing itself is a user user = self # find anyone who's tagged in a status, for example - mentions = self.mention_users if hasattr(self, 'mention_users') else [] + mentions = self.mention_users.all() if \ + hasattr(self, 'mention_users') else [] # we always send activities to explicitly mentioned users' inboxes - recipients = [u.inbox for u in mentions.all() or []] + recipients = [u.inbox for u in mentions or []] # unless it's a dm, all the followers should receive the activity if privacy != 'direct': diff --git a/bookwyrm/tests/models/test_activitypub_mixin.py b/bookwyrm/tests/models/test_activitypub_mixin.py index 36e1fcad1..ba6c14894 100644 --- a/bookwyrm/tests/models/test_activitypub_mixin.py +++ b/bookwyrm/tests/models/test_activitypub_mixin.py @@ -88,6 +88,14 @@ class ActivitypubMixins(TestCase): self.assertEqual(result, book) + def test_get_recipients(self): + ''' determines the recipients for a broadcast ''' + MockSelf = namedtuple('Self', ('privacy')) + mock_self = MockSelf('public') + ActivitypubMixin.get_recipients(mock_self) + + + # ObjectMixin def test_to_create_activity(self): ''' wrapper for ActivityPub "create" action '''