kopia lustrzana https://github.com/snarfed/bridgy-fed
rodzic
df6b0b58ba
commit
9784686b1c
|
@ -23,6 +23,7 @@ SUPPORTED_TYPES = (
|
||||||
'Article',
|
'Article',
|
||||||
'Audio',
|
'Audio',
|
||||||
'Create',
|
'Create',
|
||||||
|
'Delete',
|
||||||
'Follow',
|
'Follow',
|
||||||
'Image',
|
'Image',
|
||||||
'Like',
|
'Like',
|
||||||
|
@ -128,6 +129,15 @@ class InboxHandler(common.Handler):
|
||||||
if type == 'Undo' and obj.get('type') == 'Follow':
|
if type == 'Undo' and obj.get('type') == 'Follow':
|
||||||
# skip actor fetch below; we don't need it to undo a follow
|
# skip actor fetch below; we don't need it to undo a follow
|
||||||
return self.undo_follow(self.redirect_unwrap(activity))
|
return self.undo_follow(self.redirect_unwrap(activity))
|
||||||
|
elif type == 'Delete':
|
||||||
|
id = obj.get('id')
|
||||||
|
if isinstance(id, str):
|
||||||
|
# assume this is an actor
|
||||||
|
# https://github.com/snarfed/bridgy-fed/issues/63
|
||||||
|
for key in Follower.query().iter(keys_only=True):
|
||||||
|
if key.id().split(' ')[-1] == id:
|
||||||
|
key.delete()
|
||||||
|
return
|
||||||
|
|
||||||
# fetch actor if necessary so we have name, profile photo, etc
|
# fetch actor if necessary so we have name, profile photo, etc
|
||||||
for elem in obj, activity:
|
for elem in obj, activity:
|
||||||
|
|
|
@ -130,6 +130,15 @@ UNDO_FOLLOW_WRAPPED = {
|
||||||
'object': FOLLOW_WRAPPED,
|
'object': FOLLOW_WRAPPED,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DELETE = {
|
||||||
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
|
'id': 'https://mastodon.social/users/swentel#delete',
|
||||||
|
'type': 'Delete',
|
||||||
|
'actor': 'https://mastodon.social/users/swentel',
|
||||||
|
'object': 'https://mastodon.social/users/swentel',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@patch('requests.post')
|
@patch('requests.post')
|
||||||
@patch('requests.get')
|
@patch('requests.get')
|
||||||
@patch('requests.head')
|
@patch('requests.head')
|
||||||
|
@ -397,3 +406,16 @@ class ActivityPubTest(testutil.TestCase):
|
||||||
'object': 'http://snarfed.org/',
|
'object': 'http://snarfed.org/',
|
||||||
}).encode())
|
}).encode())
|
||||||
self.assertEqual(501, got.status_int)
|
self.assertEqual(501, got.status_int)
|
||||||
|
|
||||||
|
def test_inbox_delete_actor(self, mock_head, mock_get, mock_post):
|
||||||
|
follower = Follower.get_or_create('realize.be', DELETE['actor'])
|
||||||
|
Follower.get_or_create('snarfed.org', DELETE['actor'])
|
||||||
|
# other unrelated follower
|
||||||
|
other = Follower.get_or_create('realize.be', 'https://mas.to/users/other')
|
||||||
|
self.assertEqual(3, Follower.query().count())
|
||||||
|
|
||||||
|
got = application.get_response('/realize.be/inbox', method='POST',
|
||||||
|
body=json_dumps(DELETE).encode())
|
||||||
|
self.assertEqual(200, got.status_int)
|
||||||
|
|
||||||
|
self.assertEqual([other], Follower.query().fetch())
|
||||||
|
|
Ładowanie…
Reference in New Issue