accept Updates to Person objects, do nothing with them

fixes #387
pull/389/head
Ryan Barrett 2023-01-25 19:44:48 -08:00
rodzic d85ffaec04
commit d724ae8cba
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 36 dodań i 1 usunięć

Wyświetl plik

@ -31,6 +31,7 @@ SUPPORTED_TYPES = (
'Like',
'Note',
'Undo',
'Update',
'Video',
)
@ -80,6 +81,11 @@ def inbox(domain=None):
# skip actor fetch below; we don't need it to undo a follow
undo_follow(redirect_unwrap(activity))
return ''
elif type == 'Update':
if obj.get('type') == 'Person':
return '' # noop
else:
error(f'Sorry, {type} activities are not supported yet.', status=501)
elif type == 'Delete':
# we currently only actually delete followers for Deletes that are sent
# to the shared inbox, not individual users' inboxes, to help scaling

Wyświetl plik

@ -148,6 +148,26 @@ DELETE = {
'object': 'https://mastodon.social/users/swentel',
}
UPDATE_PERSON = {
'@context': 'https://www.w3.org/ns/activitystreams',
'id': 'https://a/person#update',
'type': 'Update',
'actor': 'https://mastodon.social/users/swentel',
'object': {
'type': 'Person',
'id': 'https://a/person',
},
}
UPDATE_NOTE = {
'@context': 'https://www.w3.org/ns/activitystreams',
'id': 'https://a/note#update',
'type': 'Update',
'actor': 'https://mastodon.social/users/swentel',
'object': {
'type': 'Note',
'id': 'https://a/note',
},
}
@patch('requests.post')
@patch('requests.get')
@ -652,6 +672,16 @@ class ActivityPubTest(testutil.TestCase):
self.assertEqual('inactive', followee.key.get().status)
self.assertEqual('active', other.key.get().status)
def test_update_person_noop(self, _, __, ___):
"""Updates to Person objects do nothing."""
got = self.client.post('/inbox', json=UPDATE_PERSON)
self.assertEqual(200, got.status_code)
def test_update_note_not_implemented(self, _, __, ___):
"""Updates to non-Person objects are not implemented."""
got = self.client.post('/inbox', json=UPDATE_NOTE)
self.assertEqual(501, got.status_code)
def test_inbox_webmention_discovery_connection_fails(self, mock_head,
mock_get, mock_post):
mock_get.side_effect = [
@ -817,7 +847,6 @@ class ActivityPubTest(testutil.TestCase):
'items': [ACTOR],
}, resp.json)
def test_outbox_empty(self, _, mock_get, __):
resp = self.client.get(f'/foo.com/outbox')
self.assertEqual(200, resp.status_code)