From fd63767263850372d1c8e4d80b23793bd5be3c7e Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Sat, 22 Feb 2020 01:31:46 +0200 Subject: [PATCH] Fix sharedInbox from remote ActivityPub profiles Fix reading `sharedInbox` from remote ActivityPub profiles. This caused public payloads not to be deduplicated when sending public payloads to remote ActivityPub servers. Refetching profiles should now fix this. Closes #124 --- CHANGELOG.md | 6 +++++- federation/entities/activitypub/mappers.py | 4 ++-- federation/tests/entities/activitypub/test_mappers.py | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a836af5..e441fd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,7 +49,11 @@ to be set, not just `target_id`. This fixes follows over the Diaspora protocol which broke with stricter send validation added in 0.19.0. -* Fix some edge case crashes of `handle_send` when there are Diaspora protocol receivers. +* Fix some edge case crashes of `handle_send` when there are Diaspora protocol receivers. + +* Fix reading `sharedInbox` from remote ActivityPub profiles. This caused public payloads not + to be deduplicated when sending public payloads to remote ActivityPub servers. Refetching + profiles should now fix this. ([related issue](https://git.feneas.org/jaywink/federation/issues/124)) ## [0.19.0] - 2019-12-15 diff --git a/federation/entities/activitypub/mappers.py b/federation/entities/activitypub/mappers.py index 8538f0c..4254f96 100644 --- a/federation/entities/activitypub/mappers.py +++ b/federation/entities/activitypub/mappers.py @@ -272,11 +272,11 @@ def transform_attribute( # Assume HTML by convention transformed["_rendered_content"] = payload.get('content').strip() transformed["_media_type"] = "text/html" - elif key == "inboxes" and isinstance(value, dict): + elif key == "endpoints" and isinstance(value, dict): if "inboxes" not in transformed: transformed["inboxes"] = {"private": None, "public": None} if value.get('sharedInbox'): - transformed["endpoints"]["public"] = value.get("sharedInbox") + transformed["inboxes"]["public"] = value.get("sharedInbox") elif key == "icon": # TODO maybe we should ditch these size constants and instead have a more flexible dict for images # so based on protocol there would either be one url or many by size name diff --git a/federation/tests/entities/activitypub/test_mappers.py b/federation/tests/entities/activitypub/test_mappers.py index 6d1b685..c50bfae 100644 --- a/federation/tests/entities/activitypub/test_mappers.py +++ b/federation/tests/entities/activitypub/test_mappers.py @@ -171,6 +171,10 @@ class TestActivitypubEntityMappersReceive: assert len(entities) == 1 profile = entities[0] assert profile.id == "https://diaspodon.fr/users/jaywink" + assert profile.inboxes == { + "private": "https://diaspodon.fr/users/jaywink/inbox", + "public": "https://diaspodon.fr/inbox", + } assert profile.handle == "" assert profile.name == "Jason Robinson" assert profile.image_urls == {