kopia lustrzana https://gitlab.com/jaywink/federation
Extract Diaspora guid
Diaspora entity guid will now be extracted from ActivityPub payloads implementing the Diaspora extension.merge-requests/161/head
rodzic
b4cc7071f4
commit
9972b9d3fb
|
@ -23,6 +23,8 @@
|
|||
|
||||
The function will be called for each generated payload.
|
||||
|
||||
* Diaspora entity guid will now be extracted from ActivityPub payloads implementing the Diaspora extension.
|
||||
|
||||
### Changed
|
||||
|
||||
* The NodeInfo2 hostmeta parser now cleans the port out of the host name.
|
||||
|
|
|
@ -227,7 +227,7 @@ def get_outbound_entity(entity: BaseEntity, private_key):
|
|||
|
||||
|
||||
def message_to_objects(
|
||||
message: Dict, sender: str, sender_key_fetcher: Callable[[str], str] = None, user: UserType = None,
|
||||
message: Dict, sender: str = "", sender_key_fetcher: Callable[[str], str] = None, user: UserType = None,
|
||||
) -> List:
|
||||
"""
|
||||
Takes in a message extracted by a protocol and maps it to entities.
|
||||
|
@ -267,6 +267,8 @@ def transform_attribute(
|
|||
transformed["_media_type"] = "text/html"
|
||||
transformed["raw_content"] = payload.get('content').strip()
|
||||
transformed["_rendered_content"] = transformed["raw_content"]
|
||||
elif key == "diaspora:guid":
|
||||
transformed["guid"] = value
|
||||
elif key == "endpoints" and isinstance(value, dict):
|
||||
if "inboxes" not in transformed:
|
||||
transformed["inboxes"] = {"private": None, "public": None}
|
||||
|
|
|
@ -12,7 +12,7 @@ from federation.tests.fixtures.payloads import (
|
|||
ACTIVITYPUB_FOLLOW, ACTIVITYPUB_PROFILE, ACTIVITYPUB_PROFILE_INVALID, ACTIVITYPUB_UNDO_FOLLOW, ACTIVITYPUB_POST,
|
||||
ACTIVITYPUB_COMMENT, ACTIVITYPUB_RETRACTION, ACTIVITYPUB_SHARE, ACTIVITYPUB_RETRACTION_SHARE,
|
||||
ACTIVITYPUB_POST_IMAGES, ACTIVITYPUB_POST_WITH_SOURCE_MARKDOWN, ACTIVITYPUB_POST_WITH_TAGS,
|
||||
ACTIVITYPUB_POST_WITH_SOURCE_BBCODE, ACTIVITYPUB_POST_WITH_MENTIONS)
|
||||
ACTIVITYPUB_POST_WITH_SOURCE_BBCODE, ACTIVITYPUB_POST_WITH_MENTIONS, ACTIVITYPUB_PROFILE_WITH_DIASPORA_GUID)
|
||||
from federation.types import UserType, ReceiverVariant
|
||||
|
||||
|
||||
|
@ -206,6 +206,15 @@ class TestActivitypubEntityMappersReceive:
|
|||
assert profile.nsfw is False
|
||||
assert profile.tag_list == []
|
||||
|
||||
def test_message_to_objects_profile__diaspora_guid_extracted(self):
|
||||
entities = message_to_objects(
|
||||
ACTIVITYPUB_PROFILE_WITH_DIASPORA_GUID, "https://friendica.feneas.org/profile/feneas",
|
||||
)
|
||||
assert len(entities) == 1
|
||||
profile = entities[0]
|
||||
assert profile.id == "https://friendica.feneas.org/profile/feneas"
|
||||
assert profile.guid == "76158462365bd347844d248732383358"
|
||||
|
||||
def test_message_to_objects_receivers_are_saved(self):
|
||||
# noinspection PyTypeChecker
|
||||
entities = message_to_objects(
|
||||
|
|
|
@ -144,6 +144,58 @@ ACTIVITYPUB_PROFILE_INVALID = {
|
|||
},
|
||||
}
|
||||
|
||||
ACTIVITYPUB_PROFILE_WITH_DIASPORA_GUID = {
|
||||
"@context": [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://w3id.org/security/v1",
|
||||
{
|
||||
"vcard": "http://www.w3.org/2006/vcard/ns#",
|
||||
"dfrn": "http://purl.org/macgirvin/dfrn/1.0/",
|
||||
"diaspora": "https://diasporafoundation.org/ns/",
|
||||
"litepub": "http://litepub.social/ns#",
|
||||
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
|
||||
"sensitive": "as:sensitive",
|
||||
"Hashtag": "as:Hashtag",
|
||||
"directMessage": "litepub:directMessage"
|
||||
}
|
||||
],
|
||||
"id": "https://friendica.feneas.org/profile/feneas",
|
||||
"diaspora:guid": "76158462365bd347844d248732383358",
|
||||
"type": "Organization",
|
||||
"following": "https://friendica.feneas.org/following/feneas",
|
||||
"followers": "https://friendica.feneas.org/followers/feneas",
|
||||
"inbox": "https://friendica.feneas.org/inbox/feneas",
|
||||
"outbox": "https://friendica.feneas.org/outbox/feneas",
|
||||
"preferredUsername": "feneas",
|
||||
"name": "Federated Networks Association",
|
||||
"vcard:hasAddress": {
|
||||
"@type": "vcard:Home",
|
||||
"vcard:country-name": "",
|
||||
"vcard:region": "",
|
||||
"vcard:locality": ""
|
||||
},
|
||||
"summary": "Federated Networks Association Ry is a non-profit volunteer organization that aims to spread knowledge about federated web projects and help people and projects involved in this area.",
|
||||
"url": "https://friendica.feneas.org/profile/feneas",
|
||||
"manuallyApprovesFollowers": False,
|
||||
"publicKey": {
|
||||
"id": "https://friendica.feneas.org/profile/feneas#main-key",
|
||||
"owner": "https://friendica.feneas.org/profile/feneas",
|
||||
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAtrN/RR6tSG0oH+G1oZmR\nHLx90i7ZgLAviJkfudnrgQDdSk5PKobKKyKw/GW07CuGtispNbI1nls3DdwnnPPl\naQYAvMW0MdLyPtviETecNcwRMMo4zOJxUMVooxjaK1bLstSxSbXpXXXWnn1niFkV\n+tHvtXXPJ12vXGoZjz0hKqzfKCND27rXCwFuecgvmMO8qeJB8aiJH5XfTPhAR0u1\nnA1Y2+GIdHP0Tnmt27nG0+9v9UqzIwlXOWRS2c5bG5XXZ35EnQEnfU9C+fhBzYEF\nBe5FwMR/sbK+a75ii0KxpP8x97MUnTkeuY7NgqY7GXJeKa9EZWK9xL7o5WDL5joe\ndNbDtyDL1CvUAB2JN+FabqbPeeHR1E5SFppBU7u0jyWTMejUqagBXdbf/Y6l7SRd\nJd51mSpmTkO9voybny7iXF4F2THZX0ZN77rDWYB8+NHAjdomfpz/wMwaaSALN6ZM\nSLxuobD0X3Rsv/2gDVL63UEXixQk4ZKBXfdZY2BmEKTKBezoWhR5yAbvTUPoklqL\nk98ajd9SIhE/YZD6nXD1S8CPiaV7qhw+2zdPIZDgq/S2P57eXcHam5ZasSzQGoo/\npVNvWzlRUo0GLIWEuA9FHklVpbuFlthaf5SP5qjKCtbYqLlzBPcxWaI0Y8Ei9ZL2\nTaosv23vnPSkN5wZp15lCrECAwEAAQ==\n-----END PUBLIC KEY-----\n"
|
||||
},
|
||||
"endpoints": {
|
||||
"sharedInbox": "https://friendica.feneas.org/inbox"
|
||||
},
|
||||
"icon": {
|
||||
"type": "Image",
|
||||
"url": "https://friendica.feneas.org/photo/11107142045be6113fe88d7733317204-4.jpg?ts=1541804364"
|
||||
},
|
||||
"generator": {
|
||||
"type": "Service",
|
||||
"name": "Friendica 'Dalmatian Bellflower' 2019.12-1327",
|
||||
"url": "https://friendica.feneas.org"
|
||||
}
|
||||
}
|
||||
|
||||
ACTIVITYPUB_RETRACTION = {
|
||||
'@context': [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
|
|
Ładowanie…
Reference in New Issue