kopia lustrzana https://gitlab.com/jaywink/federation
Mark ActivityPub entity as public if public namespace in receivers
rodzic
9fd4038039
commit
b5d739f00a
|
@ -7,3 +7,5 @@ CONTEXT_SENSITIVE = {"sensitive": "as:sensitive"}
|
|||
CONTEXTS_DEFAULT = [
|
||||
CONTEXT_ACTIVITYSTREAMS,
|
||||
]
|
||||
|
||||
NAMESPACE_PUBLIC = "https://www.w3.org/ns/activitystreams#Public"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import logging
|
||||
from typing import List, Callable, Dict, Union
|
||||
|
||||
from federation.entities.activitypub.constants import NAMESPACE_PUBLIC
|
||||
from federation.entities.activitypub.entities import (
|
||||
ActivitypubFollow, ActivitypubProfile, ActivitypubAccept, ActivitypubPost)
|
||||
from federation.entities.base import Follow, Profile, Accept, Post
|
||||
|
@ -169,6 +170,9 @@ def transform_attribute(key: str, value: Union[str, Dict, int], transformed: Dic
|
|||
transformed["public_key"] = value.get('publicKeyPem', '')
|
||||
elif key == "summary" and cls == ActivitypubProfile:
|
||||
transformed["raw_content"] = value
|
||||
elif key in ("to", "cc"):
|
||||
if isinstance(value, list) and NAMESPACE_PUBLIC in value:
|
||||
transformed["public"] = True
|
||||
elif key == "url":
|
||||
transformed["url"] = value
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ from typing import List, Dict
|
|||
from Crypto.PublicKey.RSA import RsaKey
|
||||
from iteration_utilities import unique_everseen
|
||||
|
||||
from federation.entities.activitypub.constants import NAMESPACE_PUBLIC
|
||||
from federation.entities.mixins import BaseEntity
|
||||
from federation.protocols.activitypub.signing import get_http_authentication
|
||||
from federation.types import UserType
|
||||
|
@ -131,7 +132,7 @@ def handle_send(
|
|||
try:
|
||||
payload = handle_create_payload(entity, author_user, protocol, parent_user=parent_user)
|
||||
if public:
|
||||
payload["to"] = "https://www.w3.org/ns/activitystreams#Public"
|
||||
payload["to"] = NAMESPACE_PUBLIC
|
||||
else:
|
||||
payload["to"] = fid
|
||||
payload = json.dumps(payload).encode("utf-8")
|
||||
|
|
Ładowanie…
Reference in New Issue