Fixes fav logic and base activity test

This commit is contained in:
Mouse Reeve 2021-03-07 13:13:16 -08:00
parent 47cf77145d
commit 410e0b04bb
3 changed files with 7 additions and 3 deletions

View file

@ -7,6 +7,7 @@ from bookwyrm import activitypub
from .activitypub_mixin import ActivityMixin from .activitypub_mixin import ActivityMixin
from .base_model import BookWyrmModel from .base_model import BookWyrmModel
from . import fields from . import fields
from .status import Status
class Favorite(ActivityMixin, BookWyrmModel): class Favorite(ActivityMixin, BookWyrmModel):
''' fav'ing a post ''' ''' fav'ing a post '''
@ -20,7 +21,7 @@ class Favorite(ActivityMixin, BookWyrmModel):
@classmethod @classmethod
def ignore_activity(cls, activity): def ignore_activity(cls, activity):
''' don't bother with incoming favs of unknown statuses ''' ''' 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): def save(self, *args, **kwargs):
''' update user active time ''' ''' update user active time '''

View file

@ -208,7 +208,10 @@ class BaseActivity(TestCase):
# sets the celery task call to the function call # sets the celery task call to the function call
with patch( with patch(
'bookwyrm.activitypub.base_activity.set_related_field.delay'): '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()) self.assertIsNone(status.attachments.first())

View file

@ -484,7 +484,7 @@ class Inbox(TestCase):
'actor': 'https://example.com/users/rat', 'actor': 'https://example.com/users/rat',
'type': 'Like', 'type': 'Like',
'published': 'Mon, 25 May 2020 19:31:20 GMT', '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) views.inbox.activity_task(activity)