From 6e834713f1376f54d19dcf9f81f3a85a4a16cbbb Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Mon, 29 May 2023 19:01:25 -0700 Subject: [PATCH] when replying to Follow with Accept, include original Follow object verbatim notably, including id. fixes #522 (again) --- protocol.py | 6 +----- tests/test_activitypub.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/protocol.py b/protocol.py index 4e77f124..fd165def 100644 --- a/protocol.py +++ b/protocol.py @@ -284,11 +284,7 @@ class Protocol: 'id': common.host_url(f'/user/{g.user.key.id()}/followers#accept-{obj.key.id()}'), 'type': 'Accept', 'actor': followee_actor_url, - 'object': { - 'type': 'Follow', - 'actor': follower_id, - 'object': followee_actor_url, - } + 'object': as2.from_as1(obj.as1), } return cls.send(Object(as2=accept), inbox) diff --git a/tests/test_activitypub.py b/tests/test_activitypub.py index f86c22c4..9404e3f3 100644 --- a/tests/test_activitypub.py +++ b/tests/test_activitypub.py @@ -153,15 +153,17 @@ FOLLOW_WRAPPED_WITH_ACTOR['actor'] = ACTOR FOLLOW_WITH_OBJECT = copy.deepcopy(FOLLOW) FOLLOW_WITH_OBJECT['object'] = ACTOR +ACCEPT_FOLLOW = copy.deepcopy(FOLLOW_WITH_ACTOR) +del ACCEPT_FOLLOW['actor']['@context'] +ACCEPT_FOLLOW['actor']['image'] = {'type': 'Image', 'url': 'https://user.com/me.jpg'} ACCEPT = { '@context': 'https://www.w3.org/ns/activitystreams', 'type': 'Accept', 'id': 'http://localhost/user/user.com/followers#accept-https://mas.to/6d1a', 'actor': 'http://localhost/user.com', 'object': { - 'type': 'Follow', - 'actor': 'https://mas.to/users/swentel', - 'object': 'http://localhost/user.com', + **ACCEPT_FOLLOW, + 'url': 'https://mas.to/users/swentel#followed-https://user.com/', }, } @@ -648,13 +650,14 @@ class ActivityPubTest(TestCase): 'id': FOLLOW['object'], 'url': FOLLOW['object'], } - follow = { **FOLLOW, 'object': unwrapped_user, } + accept = copy.deepcopy(ACCEPT) + accept['object']['object'] = unwrapped_user - self._test_inbox_follow_accept(follow, ACCEPT, *mocks) + self._test_inbox_follow_accept(follow, accept, *mocks) follower = Follower.query().get() follow.update({