diff --git a/tests/activities/models/test_post.py b/tests/activities/models/test_post.py index d44b963..6688ef6 100644 --- a/tests/activities/models/test_post.py +++ b/tests/activities/models/test_post.py @@ -362,9 +362,7 @@ def test_inbound_posts( InboxMessage.objects.create(message=message) # Run stator and ensure that made the post - print("prestat") stator.run_single_cycle_sync() - print("poststat") post = Post.objects.get(object_uri="https://remote.test/test-post") assert post.content == "post version one" assert post.published.day == 13 @@ -430,6 +428,28 @@ def test_inbound_posts( stator.run_single_cycle_sync() assert not Post.objects.filter(object_uri="https://remote.test/test-post").exists() + # Create an inbound new post message with only contentMap + message = { + "id": "test", + "type": "Create", + "actor": remote_identity.actor_uri, + "object": { + "id": "https://remote.test/test-map-only", + "type": "Note", + "published": "2022-11-13T23:20:16Z", + "attributedTo": remote_identity.actor_uri, + "contentMap": {"und": "post with only content map"}, + }, + } + InboxMessage.objects.create(message=message) + + # Run stator and ensure that made the post + stator.run_single_cycle_sync() + post = Post.objects.get(object_uri="https://remote.test/test-map-only") + assert post.content == "post with only content map" + assert post.published.day == 13 + assert post.url == "https://remote.test/test-map-only" + @pytest.mark.django_db def test_post_hashtag_to_ap(identity: Identity, config_system): diff --git a/users/models/inbox_message.py b/users/models/inbox_message.py index 87d0bb2..717d311 100644 --- a/users/models/inbox_message.py +++ b/users/models/inbox_message.py @@ -222,4 +222,5 @@ class InboxMessage(StatorModel): @property def message_object_has_content(self): - return "content" in self.message.get("object", {}) + object = self.message.get("object", {}) + return "content" in object or "contentMap" in object