Skip to content

.activity_pub.server

cattle_grid.database

account

ActorStatus

Bases: StrEnum

Status actors can have for an account

Source code in cattle_grid/database/account.py
class ActorStatus(StrEnum):
    """Status actors can have for an account"""

    active = auto()
    deleted = auto()

activity_pub

Base

Bases: AsyncAttrs, DeclarativeBase

Base model

Source code in cattle_grid/database/activity_pub.py
6
7
8
9
class Base(AsyncAttrs, DeclarativeBase):
    """Base model"""

    pass

Credential

Bases: Base

Stored credential

Source code in cattle_grid/database/activity_pub.py
class Credential(Base):
    """Stored credential"""

    __tablename__ = "credential"
    """name of the table"""

    id: Mapped[int] = mapped_column(primary_key=True)
    """primary key"""

    actor_id: Mapped[str] = mapped_column(String(256))
    """The id of the actor the key belongs to"""
    identifier: Mapped[str] = mapped_column(String(256), unique=True)
    """The identifier of the key"""

    secret: Mapped[str] = mapped_column(Text())
    """The secret underlying the private key"""
__tablename__ class-attribute instance-attribute
__tablename__ = 'credential'

name of the table

actor_id class-attribute instance-attribute
actor_id: Mapped[str] = mapped_column(String(256))

The id of the actor the key belongs to

id class-attribute instance-attribute
id: Mapped[int] = mapped_column(primary_key=True)

primary key

identifier class-attribute instance-attribute
identifier: Mapped[str] = mapped_column(
    String(256), unique=True
)

The identifier of the key

secret class-attribute instance-attribute
secret: Mapped[str] = mapped_column(Text())

The secret underlying the private key

InboxLocation

Bases: Base

Describes the location of an inbox. Used to send ActivityPub Activities addressed to the actor to the corresponding inbox.

This information is also collected for remote actors.

Source code in cattle_grid/database/activity_pub.py
class InboxLocation(Base):
    """Describes the location of an inbox. Used to send
    ActivityPub Activities addressed to the actor to the
    corresponding inbox.

    This information is also collected for remote actors.
    """

    __tablename__ = "inboxlocation"

    id: Mapped[int] = mapped_column(primary_key=True)
    actor: Mapped[str] = mapped_column(String(256), unique=True)
    inbox: Mapped[str] = mapped_column(String(256))

activity_pub_actor

Actor

Bases: Base

Source code in cattle_grid/database/activity_pub_actor.py
class Actor(Base):
    __tablename__ = "actor"

    id: Mapped[int] = mapped_column(primary_key=True)
    actor_id: Mapped[str] = mapped_column(String(256), unique=True)
    """The id of the actor"""
    inbox_uri: Mapped[str] = mapped_column(String(256), unique=True)
    """The uri of the inbox"""
    outbox_uri: Mapped[str] = mapped_column(String(256), unique=True)
    """The uri of the outbox"""
    following_uri: Mapped[str] = mapped_column(String(256), unique=True)
    """The uri of the following collection"""
    followers_uri: Mapped[str] = mapped_column(String(256), unique=True)
    """The uri of the followers collection"""

    preferred_username: Mapped[str] = mapped_column(String(256), nullable=True)
    """The preferred username, used as the username part of the
    acct-uri of the actor, i.e. `acct:${preferred_username}@domain`.
    See [RFC 7565 The 'acct' URI Scheme](https://www.rfc-editor.org/rfc/rfc7565.html)."""

    public_key_name: Mapped[str] = mapped_column(String(256))
    """The name given to the public key, i.e. the id will be
    `${actor_id}#${public_key_name}."""
    public_key: Mapped[str] = mapped_column(Text())
    """The public key"""

    automatically_accept_followers: Mapped[bool] = mapped_column(Boolean())
    """Set to true to indicate cattle_grid should automatically
    accept follow requests"""
    profile: Mapped[dict] = mapped_column(JSON())
    """Additional profile values"""

    status: Mapped[ActorStatus] = mapped_column(String(7))
    """Represents the status of the actor"""

    created_at: Mapped[datetime] = mapped_column(server_default=func.now())

    identifiers: Mapped[list["PublicIdentifier"]] = relationship(viewonly=True)
    followers: Mapped[list["Follower"]] = relationship(viewonly=True)
    following: Mapped[list["Following"]] = relationship(viewonly=True)
    blocking: Mapped[list["Blocking"]] = relationship(viewonly=True)
actor_id class-attribute instance-attribute
actor_id: Mapped[str] = mapped_column(
    String(256), unique=True
)

The id of the actor

automatically_accept_followers class-attribute instance-attribute
automatically_accept_followers: Mapped[bool] = (
    mapped_column(Boolean())
)

Set to true to indicate cattle_grid should automatically accept follow requests

followers_uri class-attribute instance-attribute
followers_uri: Mapped[str] = mapped_column(
    String(256), unique=True
)

The uri of the followers collection

following_uri class-attribute instance-attribute
following_uri: Mapped[str] = mapped_column(
    String(256), unique=True
)

The uri of the following collection

inbox_uri class-attribute instance-attribute
inbox_uri: Mapped[str] = mapped_column(
    String(256), unique=True
)

The uri of the inbox

outbox_uri class-attribute instance-attribute
outbox_uri: Mapped[str] = mapped_column(
    String(256), unique=True
)

The uri of the outbox

preferred_username class-attribute instance-attribute
preferred_username: Mapped[str] = mapped_column(
    String(256), nullable=True
)

The preferred username, used as the username part of the acct-uri of the actor, i.e. acct:${preferred_username}@domain. See RFC 7565 The ‘acct’ URI Scheme.

profile class-attribute instance-attribute
profile: Mapped[dict] = mapped_column(JSON())

Additional profile values

public_key class-attribute instance-attribute
public_key: Mapped[str] = mapped_column(Text())

The public key

public_key_name class-attribute instance-attribute
public_key_name: Mapped[str] = mapped_column(String(256))

The name given to the public key, i.e. the id will be `${actor_id}#${public_key_name}.

status class-attribute instance-attribute
status: Mapped[ActorStatus] = mapped_column(String(7))

Represents the status of the actor

ActorStatus

Bases: StrEnum

Represents the status of the actor

Source code in cattle_grid/database/activity_pub_actor.py
class ActorStatus(StrEnum):
    """Represents the status of the actor"""

    active = auto()
    deleted = auto()

Blocking

Bases: Base

The people the actor is blocking

Source code in cattle_grid/database/activity_pub_actor.py
class Blocking(Base):
    """The people the actor is blocking"""

    __tablename__ = "blocking"
    id: Mapped[int] = mapped_column(primary_key=True)
    actor_id: Mapped[int] = mapped_column(ForeignKey("actor.id", ondelete="CASCADE"))
    actor: Mapped[Actor] = relationship()

    blocking: Mapped[str] = mapped_column(String(256))
    request: Mapped[str] = mapped_column(String(256))
    active: Mapped[bool] = mapped_column(Boolean())

Follower

Bases: Base

The people that follow the actor

Source code in cattle_grid/database/activity_pub_actor.py
class Follower(Base):
    """The people that follow the actor"""

    __tablename__ = "follower"
    id: Mapped[int] = mapped_column(primary_key=True)
    actor_id: Mapped[int] = mapped_column(ForeignKey("actor.id", ondelete="CASCADE"))
    actor: Mapped[Actor] = relationship()

    follower: Mapped[str] = mapped_column(String(256))
    request: Mapped[str] = mapped_column(String(256))
    accepted: Mapped[bool] = mapped_column(Boolean())

Following

Bases: Base

The people the actor is following

Source code in cattle_grid/database/activity_pub_actor.py
class Following(Base):
    """The people the actor is following"""

    __tablename__ = "following"
    id: Mapped[int] = mapped_column(primary_key=True)
    actor_id: Mapped[int] = mapped_column(ForeignKey("actor.id", ondelete="CASCADE"))
    actor: Mapped[Actor] = relationship()

    following: Mapped[str] = mapped_column(String(256))
    request: Mapped[str] = mapped_column(String(256))
    accepted: Mapped[bool] = mapped_column(Boolean())

PublicIdentifier

Bases: Base

Public identifier

Source code in cattle_grid/database/activity_pub_actor.py
class PublicIdentifier(Base):
    """Public identifier"""

    __tablename__ = "publicidentifier"
    id: Mapped[int] = mapped_column(primary_key=True)
    actor_id: Mapped[int] = mapped_column(ForeignKey("actor.id", ondelete="CASCADE"))
    actor: Mapped[Actor] = relationship(lazy="joined")

    name: Mapped[str] = mapped_column(String(256))
    identifier: Mapped[str] = mapped_column(String(256), unique=True)
    preference: Mapped[int] = mapped_column(default=0)
    status: Mapped[PublicIdentifierStatus] = mapped_column(
        String(10), default=PublicIdentifierStatus.verified
    )

PublicIdentifierStatus

Bases: StrEnum

Represents the status of the public identifier

Source code in cattle_grid/database/activity_pub_actor.py
class PublicIdentifierStatus(StrEnum):
    """Represents the status of the public identifier"""

    unverified = auto()
    """This identifier could not be verified"""

    verified = auto()
    """This identifier was verified"""

    owned = auto()
    """This is an identifier owned by the cattle_grid instance"""
owned class-attribute instance-attribute
owned = auto()

This is an identifier owned by the cattle_grid instance

unverified class-attribute instance-attribute
unverified = auto()

This identifier could not be verified

verified class-attribute instance-attribute
verified = auto()

This identifier was verified

StoredActivity

Bases: Base

cattle_grid generates activities under some circumstances (see FIXME). These will be stored in this table

Source code in cattle_grid/database/activity_pub_actor.py
class StoredActivity(Base):
    """cattle_grid generates activities under some
    circumstances (see FIXME). These will be stored
    in this table"""

    __tablename__ = "storedactivity"
    id: Mapped[str] = mapped_column(String(256), primary_key=True)
    actor_id: Mapped[int] = mapped_column(ForeignKey("actor.id", ondelete="CASCADE"))
    actor: Mapped[Actor] = relationship(lazy="joined")

    data: Mapped[dict] = mapped_column(JSON())
    published: Mapped[datetime] = mapped_column()

auth

Base

Bases: AsyncAttrs, DeclarativeBase

Base model

Source code in cattle_grid/database/auth.py
6
7
8
9
class Base(AsyncAttrs, DeclarativeBase):
    """Base model"""

    pass

RemoteIdentity

Bases: Base

Stored activity in the database

Source code in cattle_grid/database/auth.py
class RemoteIdentity(Base):
    """Stored activity in the database"""

    __tablename__ = "cattle_grid_auth_remote_identity"
    """name of the table"""

    id: Mapped[int] = mapped_column(primary_key=True)
    """The id of the key"""

    key_id: Mapped[str] = mapped_column(String(512), unique=True)
    """The URI uniquely identifying the key"""
    controller: Mapped[str] = mapped_column(String(512))
    """The URI of te controller"""
    public_key: Mapped[str] = mapped_column(String(1024))
    """The public key"""
__tablename__ class-attribute instance-attribute
__tablename__ = 'cattle_grid_auth_remote_identity'

name of the table

controller class-attribute instance-attribute
controller: Mapped[str] = mapped_column(String(512))

The URI of te controller

id class-attribute instance-attribute
id: Mapped[int] = mapped_column(primary_key=True)

The id of the key

key_id class-attribute instance-attribute
key_id: Mapped[str] = mapped_column(
    String(512), unique=True
)

The URI uniquely identifying the key

public_key class-attribute instance-attribute
public_key: Mapped[str] = mapped_column(String(1024))

The public key