kopia lustrzana https://github.com/snarfed/bridgy-fed
rodzic
8f7facda97
commit
ee373095e2
|
@ -641,8 +641,13 @@ class Protocol:
|
|||
actor_id = actor.get('id')
|
||||
|
||||
# handle activity!
|
||||
if obj.type == 'accept': # eg in response to a Follow
|
||||
return 'OK' # noop
|
||||
|
||||
# accept, eg in response to a follow. only send if the destination
|
||||
# supports accepts.
|
||||
if obj.type == 'accept':
|
||||
to_cls = Protocol.for_id(inner_obj_id)
|
||||
if not to_cls or not to_cls.HAS_FOLLOW_ACCEPTS:
|
||||
return 'OK' # noop
|
||||
|
||||
elif obj.type == 'stop-following':
|
||||
# TODO: unify with handle_follow?
|
||||
|
|
|
@ -1381,6 +1381,35 @@ class ProtocolReceiveTest(TestCase):
|
|||
self.assertEqual([], Follower.query().fetch())
|
||||
self.assertEqual([], Fake.sent)
|
||||
|
||||
def test_accept_noop(self, **extra):
|
||||
eve = self.make_user('other:eve', cls=OtherFake)
|
||||
accept_as1 = {
|
||||
'id': 'other:accept',
|
||||
'objectType': 'activity',
|
||||
'verb': 'accept',
|
||||
'actor': 'other:eve',
|
||||
'object': 'fake:follow'
|
||||
}
|
||||
|
||||
self.assertEqual('OK', OtherFake.receive_as1(accept_as1))
|
||||
self.assertEqual([], Fake.sent)
|
||||
self.assertEqual([], OtherFake.sent)
|
||||
|
||||
def test_accept_with_has_accepts_protocol(self, **extra):
|
||||
OtherFake.fetchable['other:follow'] = {'id': 'other:follow'}
|
||||
accept_as1 = {
|
||||
'id': 'fake:accept',
|
||||
'objectType': 'activity',
|
||||
'verb': 'accept',
|
||||
'actor': 'fake:alice',
|
||||
'object': 'other:follow'
|
||||
}
|
||||
|
||||
self.assertEqual(('OK', 202), Fake.receive_as1(accept_as1))
|
||||
self.assertEqual([
|
||||
('fake:accept', 'other:follow:target'),
|
||||
], OtherFake.sent)
|
||||
|
||||
def test_stop_following(self):
|
||||
follower = Follower.get_or_create(to=self.user, from_=self.alice)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue