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):
|
class ActivitypubAccept(ActivitypubObjectMixin, Accept):
|
||||||
_type = ActivityType.ACCEPT.value
|
_type = ActivityType.ACCEPT.value
|
||||||
|
object: Dict = None
|
||||||
|
|
||||||
def to_as2(self) -> Dict:
|
def to_as2(self) -> Dict:
|
||||||
as2 = {
|
as2 = {
|
||||||
|
@ -24,7 +25,7 @@ class ActivitypubAccept(ActivitypubObjectMixin, Accept):
|
||||||
"id": self.activity_id,
|
"id": self.activity_id,
|
||||||
"type": self._type,
|
"type": self._type,
|
||||||
"actor": self.actor_id,
|
"actor": self.actor_id,
|
||||||
"object": self.target_id,
|
"object": self.object,
|
||||||
}
|
}
|
||||||
return as2
|
return as2
|
||||||
|
|
||||||
|
@ -53,6 +54,7 @@ class ActivitypubFollow(ActivitypubObjectMixin, Follow):
|
||||||
activity_id=f"{self.target_id}#accept-{uuid.uuid4()}",
|
activity_id=f"{self.target_id}#accept-{uuid.uuid4()}",
|
||||||
actor_id=self.target_id,
|
actor_id=self.target_id,
|
||||||
target_id=self.activity_id,
|
target_id=self.activity_id,
|
||||||
|
object=self.to_as2(),
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
profile = retrieve_and_parse_profile(self.actor_id)
|
profile = retrieve_and_parse_profile(self.actor_id)
|
||||||
|
|
|
@ -17,7 +17,13 @@ class TestEntitiesConvertToAS2:
|
||||||
"id": "https://localhost/accept",
|
"id": "https://localhost/accept",
|
||||||
"type": "Accept",
|
"type": "Accept",
|
||||||
"actor": "https://localhost/profile",
|
"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):
|
def test_post_to_as2(self, activitypubpost):
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import uuid
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from freezegun import freeze_time
|
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
|
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
|
@pytest.fixture
|
||||||
def activitypubfollow():
|
def activitypubfollow():
|
||||||
return 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
|
@pytest.fixture
|
||||||
def activitypubpost():
|
def activitypubpost():
|
||||||
with freeze_time("2019-04-27"):
|
with freeze_time("2019-04-27"):
|
||||||
|
|
Ładowanie…
Reference in New Issue