Add system actor and shared inbox

pull/155/head
Andrew Godwin 2022-12-10 13:24:49 -07:00
rodzic fd52500591
commit 602e5a3780
6 zmienionych plików z 13 dodań i 1 usunięć

1
.gitignore vendored
Wyświetl plik

@ -13,4 +13,5 @@
/media/
/static-collected
__pycache__/
api-test.*
notes.md

Wyświetl plik

@ -199,6 +199,8 @@ urlpatterns = [
path(".well-known/nodeinfo", activitypub.NodeInfo.as_view()),
path("nodeinfo/2.0/", activitypub.NodeInfo2.as_view()),
path("actor/", activitypub.SystemActorView.as_view()),
path("actor/inbox/", activitypub.Inbox.as_view()),
path("inbox/", activitypub.Inbox.as_view(), name="shared_inbox"),
# Stator
path(".stator/", stator.RequestRunner.as_view()),
# Django admin

Wyświetl plik

@ -14,6 +14,7 @@ def test_webfinger_actor(client, identity):
# Fetch their actor
data = client.get("/@test@example.com/", HTTP_ACCEPT="application/ld+json").json()
assert data["id"] == "https://example.com/@test@example.com/"
assert data["endpoints"]["sharedInbox"] == "https://example.com/inbox/"
@pytest.mark.django_db
@ -31,6 +32,7 @@ def test_webfinger_system_actor(client):
data = client.get("/actor/", HTTP_ACCEPT="application/ld+json").json()
assert data["id"] == "https://example.com/actor/"
assert data["inbox"] == "https://example.com/actor/inbox/"
assert data["endpoints"]["sharedInbox"] == "https://example.com/inbox/"
@pytest.mark.django_db

Wyświetl plik

@ -296,6 +296,10 @@ class Identity(StatorModel):
"mediaType": media_type_from_filename(self.image.name),
"url": self.image.url,
}
if self.local:
response["endpoints"] = {
"sharedInbox": f"https://{self.domain.uri_domain}/inbox/",
}
return response
### ActivityPub (inbound) ###

Wyświetl plik

@ -43,6 +43,9 @@ class SystemActor:
"id": self.actor_uri,
"type": "Application",
"inbox": self.actor_uri + "inbox/",
"endpoints": {
"sharedInbox": f"https://{settings.MAIN_DOMAIN}/inbox/",
},
"preferredUsername": self.username,
"url": self.profile_uri,
"as:manuallyApprovesFollowers": True,

Wyświetl plik

@ -138,7 +138,7 @@ class Inbox(View):
AP Inbox endpoint
"""
def post(self, request, handle):
def post(self, request, handle=None):
# Load the LD
document = canonicalise(json.loads(request.body), include_security=True)
# Find the Identity by the actor on the incoming item