Skip to content

muck_out.types

These are the basic types of objects muck_out transforms things to

Activity

Bases: Common

This represents a first draft of a json-schema that every activities exchanged between servers MUST satisfy and be able to parse. Here ‘being able to parse’ means making it to the point, where depending on the type, you decide what side effects to perform.

Generally, the fields actor, to, and cc (and maybe bcc — not transported) represent how the message is being delivered. The fields actor, type, object, target, content represent how the message is processed by the server.

Parameters:

Name Type Description Default
field_context str | list[Any] | None
None
id str

id of the activity or object, can be assumed to be globally unique. Some activities such as a Follow request will require an id to be valid. Servers may assume an id to be required. As assigning an id is ‘trivial’, one should assign one.

required
to list[str]

Array of actors this activity or object is addressed to. It is sane to assume that an activity is addressed to at least one person.

required
cc list[str]

Array of actors this activity or object is carbon copied to.

[]
published datetime | None

Moment of this activity or object being published

None
type str

Type of the activity or activity. Side effects of this activity are determine by this type.

required
actor str

id of the actor performing this activity. One can assume that the activity is signed by this actor (in some form).

required
object str | Object | None
None
target str | dict[str, Any] | None

The target, not sure if needed, included for completeness

None
content str | None

The content used for example to represent the Emote for a like

None
Source code in muck_out/types/validated/__init__.py
class Activity(Common):
    """
    This represents a first draft of a json-schema that every activities exchanged between servers MUST satisfy and be able to parse. Here 'being able to parse' means making it to the point, where depending on the type, you decide what side effects to perform.

    Generally, the fields actor, to, and cc (and maybe bcc --- not transported) represent how the message is being delivered. The fields actor, type, object, target, content represent how the message is processed by the server.
    """

    actor: str = Field(
        ...,
        examples=["https://actor.example/"],
        description="""
    id of the actor performing this activity. One can assume that the activity is signed by this actor (in some form).
    """,
    )
    object: str | Object | None = Field(None)
    target: str | dict[str, Any] | None = Field(
        None,
        examples=[
            "https://other.example/target_id",
            {"type": "Note", "content": "meow"},
        ],
        description="""
    The target, not sure if needed, included for completeness
    """,
    )
    content: str | None = Field(
        None,
        examples=["🐮", "❤️"],
        description="The content used for example to represent the Emote for a like",
    )

ActivityStub

Bases: Common

This represents a first draft of a json-schema that every activities exchanged between servers MUST satisfy and be able to parse. Here ‘being able to parse’ means making it to the point, where depending on the type, you decide what side effects to perform.

Generally, the fields actor, to, and cc (and maybe bcc — not transported) represent how the message is being delivered. The fields actor, type, object, target, content represent how the message is processed by the server.

Parameters:

Name Type Description Default
field_context list[Union[str, dict]] | None

The Json-LD context

['https://www.w3.org/ns/activitystreams']
id str | None

id of the activity or object, can be assumed to be globally unique. Some activities such as a Follow request will require an id to be valid. Servers may assume an id to be required. As assigning an id is ‘trivial’, one should assign one.

None
type str | None

Type of the activity or activity. Side effects of this activity are determine by this type.

None
to list[str]

Array of actors this activity or object is addressed to. It is sane to assume that an activity is addressed to at least one person.

[]
cc list[str]

Array of actors this activity or object is carbon copied to.

[]
published datetime | None

Moment of this activity or object being published

None
actor str | None

id of the actor performing this activity. One can assume that the activity is signed by this actor (in some form).

None
object str | None

The object of the activity

None
target str | None

The target, not sure if needed, included for completeness

None
content str | None

The content used for example to represent the Emote for a like

None
Source code in muck_out/types/stubs/activity.py
class ActivityStub(Common):
    """
    This represents a first draft of a json-schema that every activities exchanged between servers MUST satisfy and be able to parse. Here 'being able to parse' means making it to the point, where depending on the type, you decide what side effects to perform.

    Generally, the fields actor, to, and cc (and maybe bcc --- not transported) represent how the message is being delivered. The fields actor, type, object, target, content represent how the message is processed by the server.
    """

    actor: IdFieldOrNone = Field(
        default=None,
        examples=["https://actor.example/"],
        description="id of the actor performing this activity. One can assume that the activity is signed by this actor (in some form).",
    )
    object: IdFieldOrNone = Field(
        default=None, description="The object of the activity"
    )
    target: IdFieldOrNone = Field(
        default=None,
        examples=[
            "https://other.example/target_id",
        ],
        description="The target, not sure if needed, included for completeness",
    )
    content: HtmlStringOrNone = Field(
        default=None,
        examples=["🐮", "❤️"],
        description="The content used for example to represent the Emote for a like",
    )

Actor

Bases: CommonAll, CommonActor

Describes an ActivityPub actor

Parameters:

Name Type Description Default
inbox str | None

The inbox of the actor

None
outbox str | None

The outbox of the actor

None
followers str | None

The followers collection of the actor

None
following str | None

The following collection of the actor

None
summary str | None

Description of the actor

None
name str | None

Display name of the actor

None
url list[dict[str, Any]]

A list of urls connected to the actor

[]
attachment list[Annotated[Union[Annotated[PropertyValue, Tag], Annotated[dict, Tag]], Discriminator]]

attachments … currently used for property values

[]
tag list[Annotated[Union[Annotated[Hashtag, Tag], Annotated[Mention, Tag], Annotated[ObjectLink, Tag], Annotated[dict, Tag], Annotated[dict, BeforeValidator, Tag]], Discriminator]]

A list of objects that expand on the summary of the actor

[]
manually_approves_followers bool | None

If set to false, one can assume that te actor automatically replies to follow requests

None
field_context str | list[Any] | None
None
id str

id of the activity or object, can be assumed to be globally unique. Some activities such as a Follow request will require an id to be valid. Servers may assume an id to be required. As assigning an id is ‘trivial’, one should assign one.

required
type str

The type of Actor

required
icon dict | None

The avatar of the actor

None
also_known_as list[str] | None

Other uris associated with the actor

None
preferred_username str | None
None
identifiers list[str]

An ordered list of identifiers

[]
Source code in muck_out/types/validated/actor.py
class Actor(CommonAll, CommonActor):
    """Describes an ActivityPub actor"""

    type: str = Field(
        examples=["Person", "Service", "Application"],
        description="""The type of Actor""",
    )

    icon: dict | None = Field(
        None,
        examples=[{"type": "Image", "url": "https://actor.example/icon.png"}],
        description="The avatar of the actor",
    )

    also_known_as: list[str] | None = Field(
        None,
        examples=[["https://alice.example", "https://alice.example/profile"]],
        alias="alsoKnownAs",
        description="Other uris associated with the actor",
    )

    preferred_username: str | None = Field(
        None, examples=["john"], alias="preferredUsername"
    )

    identifiers: ListOfStringsWithAtLeastOneElement = Field(
        default=[], description="An ordered list of identifiers"
    )

ActorStub

Bases: CommonAll, CommonActor

Describes an ActivityPub actor

Parameters:

Name Type Description Default
inbox str | None

The inbox of the actor

None
outbox str | None

The outbox of the actor

None
followers str | None

The followers collection of the actor

None
following str | None

The following collection of the actor

None
summary str | None

Description of the actor

None
name str | None

Display name of the actor

None
url list[dict[str, Any]]

A list of urls connected to the actor

[]
attachment list[Annotated[Union[Annotated[PropertyValue, Tag], Annotated[dict, Tag]], Discriminator]]

attachments … currently used for property values

[]
tag list[Annotated[Union[Annotated[Hashtag, Tag], Annotated[Mention, Tag], Annotated[ObjectLink, Tag], Annotated[dict, Tag], Annotated[dict, BeforeValidator, Tag]], Discriminator]]

A list of objects that expand on the summary of the actor

[]
manually_approves_followers bool | None

If set to false, one can assume that te actor automatically replies to follow requests

None
field_context list[Union[str, dict]] | None

The Json-LD context

['https://www.w3.org/ns/activitystreams']
id str | None

id of the activity or object, can be assumed to be globally unique. Some activities such as a Follow request will require an id to be valid. Servers may assume an id to be required. As assigning an id is ‘trivial’, one should assign one.

None
type str | None

Type of the activity or activity. Side effects of this activity are determine by this type.

None
icon dict | None

The avatar of the actor

None
also_known_as list[str] | None

Other uris associated with the actor

None
preferred_username str | None
None
identifiers list[str]

An ordered list of identifiers

[]
Source code in muck_out/types/stubs/actor.py
class ActorStub(CommonAll, CommonActor):
    """Describes an ActivityPub actor"""

    icon: dict | None = Field(
        None,
        examples=[{"type": "Image", "url": "https://actor.example/icon.png"}],
        description="The avatar of the actor",
    )

    also_known_as: list[str] | None = Field(
        None,
        examples=[["https://alice.example", "https://alice.example/profile"]],
        alias="alsoKnownAs",
        description="Other uris associated with the actor",
    )

    preferred_username: str | None = Field(
        None, examples=["john"], alias="preferredUsername"
    )

    identifiers: TransformToListOfUris = Field(
        default=[], description="An ordered list of identifiers"
    )

Collection

Bases: CommonAll

Abstracts all the ActivityPub collection concepts

Parameters:

Name Type Description Default
field_context str | list[Any] | None
None
id str

id of the activity or object, can be assumed to be globally unique. Some activities such as a Follow request will require an id to be valid. Servers may assume an id to be required. As assigning an id is ‘trivial’, one should assign one.

required
type str

Type of object

required
items list[str] | None

The items

None
next str | None
None
prev str | None
None
first str | None
None
last str | None
None
total_items int | None
None
Source code in muck_out/types/validated/collection.py
class Collection(CommonAll):
    """Abstracts all the ActivityPub collection concepts"""

    type: str = Field(
        examples=[
            "Collection",
            "OrderedCollection",
            "CollectionPage",
            "OrdererCollectionPage",
        ],
        description="""Type of object""",
    )

    items: list[str] | None = Field(None, description="""The items""")

    next: str | None = Field(None)
    prev: str | None = Field(None)
    first: str | None = Field(None)
    last: str | None = Field(None)
    total_items: int | None = Field(None, alias="totalItems")

CollectionStub

Bases: CommonAll

Abstracts all the ActivityPub collection concepts

Parameters:

Name Type Description Default
field_context list[Union[str, dict]] | None

The Json-LD context

['https://www.w3.org/ns/activitystreams']
id str | None

id of the activity or object, can be assumed to be globally unique. Some activities such as a Follow request will require an id to be valid. Servers may assume an id to be required. As assigning an id is ‘trivial’, one should assign one.

None
type str | None

Type of the activity or activity. Side effects of this activity are determine by this type.

None
items list[str]

The items

[]
next str | None
None
prev str | None
None
first str | None
None
last str | None
None
total_items int | None
None
Source code in muck_out/types/stubs/collection.py
class CollectionStub(CommonAll):
    """Abstracts all the ActivityPub collection concepts"""

    items: TransformToListOfUris = Field([], description="""The items""")

    next: IdFieldOrNone = Field(None)
    prev: IdFieldOrNone = Field(None)
    first: IdFieldOrNone = Field(None)
    last: IdFieldOrNone = Field(None)
    total_items: int | None = Field(None, alias="totalItems")

Object

Bases: Common, CommonObject

Parameters:

Name Type Description Default
updated datetime | None

Moment of this object being updated

None
summary str | None

The summary of the object

None
name str | None

The name of the object

None
in_reply_to str | None

The object being replied to. Currently a string. Not sure if this is what I want.

None
context str | None

The context of the object

None
tag list[Annotated[Union[Annotated[Hashtag, Tag], Annotated[Mention, Tag], Annotated[ObjectLink, Tag], Annotated[dict, Tag], Annotated[dict, BeforeValidator, Tag]], Discriminator]]

A list of objects that expand on the content of the object

[]
field_context str | list[Any] | None
None
id str

id of the activity or object, can be assumed to be globally unique. Some activities such as a Follow request will require an id to be valid. Servers may assume an id to be required. As assigning an id is ‘trivial’, one should assign one.

required
to list[str]

Array of actors this activity or object is addressed to. It is sane to assume that an activity is addressed to at least one person.

required
cc list[str]

Array of actors this activity or object is carbon copied to.

[]
published datetime | None

Moment of this activity or object being published

None
type str

Type of the activity or activity. Side effects of this activity are determine by this type.

required
attributed_to str

id of the actor that authored this object

required
content str | None

The content of the object

None
content_plain Annotated[str, BeforeValidator] | None

The content of the object stripped of html

None
attachment list[dict[str, Any]] | None

A list of objects that are attached to the original object

None
url list[dict[str, Any]]

A list of urls that expand on the content of the object

[]
sensitive bool | None

Marks the object as sensitive. Currently, used by everyone, a better way would be an element of the tag list that labels the object as sensitive due a reason

None
Source code in muck_out/types/validated/object.py
class Object(Common, CommonObject):
    attributed_to: str = Field(
        examples=["https://actor.example/"],
        description="id of the actor that authored this object",
        alias="attributedTo",
    )
    content: str | None = Field(default=None, description="The content of the object")
    content_plain: PlainText | None = Field(
        default=None,
        description="The content of the object stripped of html",
        alias="contentPlain",
    )

    attachment: list[dict[str, Any]] | None = Field(
        None,
        description="A list of objects that are attached to the original object",
    )
    url: list[dict[str, Any]] = Field(
        default=[],
        description="A list of urls that expand on the content of the object",
    )
    sensitive: bool | None = Field(
        None,
        description="""
    Marks the object as sensitive. Currently, used by everyone, a better way would be an element of the tag list that labels the object as sensitive due a reason
    """,
    )

ObjectStub

Bases: Common, CommonObject

Stub object

Parameters:

Name Type Description Default
updated datetime | None

Moment of this object being updated

None
summary str | None

The summary of the object

None
name str | None

The name of the object

None
in_reply_to str | None

The object being replied to. Currently a string. Not sure if this is what I want.

None
context str | None

The context of the object

None
tag list[Annotated[Union[Annotated[Hashtag, Tag], Annotated[Mention, Tag], Annotated[ObjectLink, Tag], Annotated[dict, Tag], Annotated[dict, BeforeValidator, Tag]], Discriminator]]

A list of objects that expand on the content of the object

[]
field_context list[Union[str, dict]] | None

The Json-LD context

['https://www.w3.org/ns/activitystreams']
id str | None

id of the activity or object, can be assumed to be globally unique. Some activities such as a Follow request will require an id to be valid. Servers may assume an id to be required. As assigning an id is ‘trivial’, one should assign one.

None
type str | None

Type of the activity or activity. Side effects of this activity are determine by this type.

None
to list[str]

Array of actors this activity or object is addressed to. It is sane to assume that an activity is addressed to at least one person.

[]
cc list[str]

Array of actors this activity or object is carbon copied to.

[]
published datetime | None

Moment of this activity or object being published

None
attributed_to str | None

id of the actor that authored this object

None
content str | None

The content of the object

None
attachment list[dict[str, Any]]

A list of objects that are attached to the original object

[]
url list[dict[str, Any]]

A list of urls that expand on the content of the object

[]
sensitive bool | None

Marks the object as sensitive. Currently, used by everyone, a better way would be an element of the tag list that labels the object as sensitive due a reason

None
Source code in muck_out/types/stubs/object.py
class ObjectStub(Common, CommonObject):
    """Stub object"""

    attributed_to: IdFieldOrNone = Field(
        default=None,
        examples=["https://actor.example/"],
        description="id of the actor that authored this object",
        alias="attributedTo",
    )
    content: HtmlStringOrNone = Field(
        default=None, description="The content of the object"
    )

    attachment: Annotated[
        list[dict[str, Any]], BeforeValidator(transform_attachments)
    ] = Field(
        default=[],
        description="A list of objects that are attached to the original object",
    )

    url: UrlList = Field(
        default=[],
        description="A list of urls that expand on the content of the object",
    )
    sensitive: bool | None = Field(
        None,
        description="Marks the object as sensitive. Currently, used by everyone, a better way would be an element of the tag list that labels the object as sensitive due a reason",
    )