diff --git a/bookwyrm/models/favorite.py b/bookwyrm/models/favorite.py index de500e51..d34cbcba 100644 --- a/bookwyrm/models/favorite.py +++ b/bookwyrm/models/favorite.py @@ -7,6 +7,7 @@ from bookwyrm import activitypub from .activitypub_mixin import ActivityMixin from .base_model import BookWyrmModel from . import fields +from .status import Status class Favorite(ActivityMixin, BookWyrmModel): ''' fav'ing a post ''' @@ -20,7 +21,7 @@ class Favorite(ActivityMixin, BookWyrmModel): @classmethod def ignore_activity(cls, activity): ''' don't bother with incoming favs of unknown statuses ''' - return not cls.objects.filter(remote_id=activity.object).exists() + return not Status.objects.filter(remote_id=activity.object).exists() def save(self, *args, **kwargs): ''' update user active time ''' diff --git a/bookwyrm/tests/activitypub/test_base_activity.py b/bookwyrm/tests/activitypub/test_base_activity.py index d489fdaa..de108eae 100644 --- a/bookwyrm/tests/activitypub/test_base_activity.py +++ b/bookwyrm/tests/activitypub/test_base_activity.py @@ -208,7 +208,10 @@ class BaseActivity(TestCase): # sets the celery task call to the function call with patch( 'bookwyrm.activitypub.base_activity.set_related_field.delay'): - update_data.to_model(model=models.Status, instance=status) + with patch('bookwyrm.models.status.Status.ignore_activity') \ + as discarder: + discarder.return_value = False + update_data.to_model(model=models.Status, instance=status) self.assertIsNone(status.attachments.first()) diff --git a/bookwyrm/tests/views/test_inbox.py b/bookwyrm/tests/views/test_inbox.py index b0bd3e42..4202979b 100644 --- a/bookwyrm/tests/views/test_inbox.py +++ b/bookwyrm/tests/views/test_inbox.py @@ -484,7 +484,7 @@ class Inbox(TestCase): 'actor': 'https://example.com/users/rat', 'type': 'Like', 'published': 'Mon, 25 May 2020 19:31:20 GMT', - 'object': 'https://example.com/status/1', + 'object': self.status.remote_id, } views.inbox.activity_task(activity)