mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-28 19:10:35 +00:00
parent
673d70aca9
commit
e0adb3307b
2 changed files with 12 additions and 2 deletions
|
@ -185,11 +185,15 @@ def handle_create(activity):
|
|||
''' someone did something, good on them '''
|
||||
# deduplicate incoming activities
|
||||
activity = activity['object']
|
||||
status_id = activity['id']
|
||||
status_id = activity.get('id')
|
||||
if models.Status.objects.filter(remote_id=status_id).count():
|
||||
return
|
||||
|
||||
serializer = activitypub.activity_objects[activity['type']]
|
||||
try:
|
||||
serializer = activitypub.activity_objects[activity['type']]
|
||||
except KeyError:
|
||||
return
|
||||
|
||||
activity = serializer(**activity)
|
||||
try:
|
||||
model = models.activity_models[activity.type]
|
||||
|
|
|
@ -272,6 +272,12 @@ class Incoming(TestCase):
|
|||
incoming.handle_create(activity)
|
||||
self.assertEqual(models.Status.objects.count(), 2)
|
||||
|
||||
def test_handle_create_unknown_type(self):
|
||||
''' folks send you all kinds of things '''
|
||||
activity = {'object': {'id': 'hi'}, 'type': 'Fish'}
|
||||
result = incoming.handle_create(activity)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_handle_create_remote_note_with_mention(self):
|
||||
''' should only create it under the right circumstances '''
|
||||
self.assertEqual(models.Status.objects.count(), 1)
|
||||
|
|
Loading…
Reference in a new issue