forked from mirrors/bookwyrm
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 '''
|
''' someone did something, good on them '''
|
||||||
# deduplicate incoming activities
|
# deduplicate incoming activities
|
||||||
activity = activity['object']
|
activity = activity['object']
|
||||||
status_id = activity['id']
|
status_id = activity.get('id')
|
||||||
if models.Status.objects.filter(remote_id=status_id).count():
|
if models.Status.objects.filter(remote_id=status_id).count():
|
||||||
return
|
return
|
||||||
|
|
||||||
serializer = activitypub.activity_objects[activity['type']]
|
try:
|
||||||
|
serializer = activitypub.activity_objects[activity['type']]
|
||||||
|
except KeyError:
|
||||||
|
return
|
||||||
|
|
||||||
activity = serializer(**activity)
|
activity = serializer(**activity)
|
||||||
try:
|
try:
|
||||||
model = models.activity_models[activity.type]
|
model = models.activity_models[activity.type]
|
||||||
|
|
|
@ -272,6 +272,12 @@ class Incoming(TestCase):
|
||||||
incoming.handle_create(activity)
|
incoming.handle_create(activity)
|
||||||
self.assertEqual(models.Status.objects.count(), 2)
|
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):
|
def test_handle_create_remote_note_with_mention(self):
|
||||||
''' should only create it under the right circumstances '''
|
''' should only create it under the right circumstances '''
|
||||||
self.assertEqual(models.Status.objects.count(), 1)
|
self.assertEqual(models.Status.objects.count(), 1)
|
||||||
|
|
Loading…
Reference in a new issue