kopia lustrzana https://gitlab.com/jaywink/federation
Merge branch 'fix-accept' into 'master'
Serialize accepted object into Accept See merge request jaywink/federation!145merge-requests/147/head
commit
68c956d68b
|
@ -17,6 +17,7 @@ logger = logging.getLogger("federation")
|
|||
|
||||
class ActivitypubAccept(ActivitypubObjectMixin, Accept):
|
||||
_type = ActivityType.ACCEPT.value
|
||||
object: Dict = None
|
||||
|
||||
def to_as2(self) -> Dict:
|
||||
as2 = {
|
||||
|
@ -24,7 +25,7 @@ class ActivitypubAccept(ActivitypubObjectMixin, Accept):
|
|||
"id": self.activity_id,
|
||||
"type": self._type,
|
||||
"actor": self.actor_id,
|
||||
"object": self.target_id,
|
||||
"object": self.object,
|
||||
}
|
||||
return as2
|
||||
|
||||
|
@ -53,6 +54,7 @@ class ActivitypubFollow(ActivitypubObjectMixin, Follow):
|
|||
activity_id=f"{self.target_id}#accept-{uuid.uuid4()}",
|
||||
actor_id=self.target_id,
|
||||
target_id=self.activity_id,
|
||||
object=self.to_as2(),
|
||||
)
|
||||
try:
|
||||
profile = retrieve_and_parse_profile(self.actor_id)
|
||||
|
|
|
@ -17,7 +17,13 @@ class TestEntitiesConvertToAS2:
|
|||
"id": "https://localhost/accept",
|
||||
"type": "Accept",
|
||||
"actor": "https://localhost/profile",
|
||||
"object": "https://example.com/follow/1234",
|
||||
"object": {
|
||||
"@context": CONTEXTS_DEFAULT,
|
||||
"id": "https://localhost/follow",
|
||||
"type": "Follow",
|
||||
"actor": "https://localhost/profile",
|
||||
"object": "https://example.com/profile",
|
||||
},
|
||||
}
|
||||
|
||||
def test_post_to_as2(self, activitypubpost):
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import uuid
|
||||
|
||||
import pytest
|
||||
from freezegun import freeze_time
|
||||
|
||||
|
@ -15,15 +13,6 @@ from federation.tests.fixtures.keys import PUBKEY
|
|||
from federation.tests.fixtures.payloads import DIASPORA_PUBLIC_PAYLOAD
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def activitypubaccept():
|
||||
return ActivitypubAccept(
|
||||
activity_id="https://localhost/accept",
|
||||
actor_id="https://localhost/profile",
|
||||
target_id="https://example.com/follow/1234",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def activitypubfollow():
|
||||
return ActivitypubFollow(
|
||||
|
@ -33,6 +22,16 @@ def activitypubfollow():
|
|||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def activitypubaccept(activitypubfollow):
|
||||
return ActivitypubAccept(
|
||||
activity_id="https://localhost/accept",
|
||||
actor_id="https://localhost/profile",
|
||||
target_id="https://example.com/follow/1234",
|
||||
object=activitypubfollow.to_as2(),
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def activitypubpost():
|
||||
with freeze_time("2019-04-27"):
|
||||
|
|
Ładowanie…
Reference in New Issue