.activity_pub
cattle_grid.activity_pub
get_async_api_schema
get_async_api_schema() -> Schema
Returns the async api schema for cattle_grid ActivityPub processing
get_fastapi_app
Returns the fast api app for ActivityPub processing
get_mock_faststream_app
get_mock_faststream_app() -> FastStream
Creates a mock faststream app for ActivityPub processing
Source code in cattle_grid/activity_pub/__init__.py
cattle_grid.activity_pub.activity
actor_deletes_themselves
Checks if activity is self delete of actor
>>> actor_deletes_themselves({"type": "Delete",
... "actor": "http://actor.test/",
... "object": "http://actor.test/"})
True
>>> actor_deletes_themselves({"type": "Delete",
... "actor": "http://actor.test/",
... "object": "http://other.test/"})
False
Source code in cattle_grid/activity_pub/activity.py
cattle_grid.activity_pub.actor
ActorNotFound
DuplicateIdentifierException
actor_to_object
Transform the actor to an object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
actor
|
Actor
|
|
required |
Returns:
Type | Description |
---|---|
dict
|
|
Source code in cattle_grid/activity_pub/actor/__init__.py
bovine_actor_for_actor_id
async
bovine_actor_for_actor_id(
actor_id: str,
) -> BovineActor | None
Uses the information stored in Credential to construct a bovine actor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
actor_id
|
str
|
|
required |
Returns:
Type | Description |
---|---|
BovineActor | None
|
|
Source code in cattle_grid/activity_pub/actor/__init__.py
compute_acct_uri
Computes the acct uri
Source code in cattle_grid/activity_pub/actor/__init__.py
create_actor
async
create_actor(
base_url: str,
preferred_username: str | None = None,
identifiers: dict = {},
profile: dict = {},
)
Creates a new actor in the database
Source code in cattle_grid/activity_pub/actor/__init__.py
delete_actor
async
delete_actor(actor: Actor)
Deletes an actor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
actor
|
Actor
|
Actor to be deleted |
required |
Source code in cattle_grid/activity_pub/actor/__init__.py
delete_for_actor_profile
Creates a delete activity for the Actor
Source code in cattle_grid/activity_pub/actor/__init__.py
followers_for_actor
async
following_for_actor
async
is_valid_requester
async
Checks if the requested is allowed to view the object
Source code in cattle_grid/activity_pub/actor/__init__.py
is_valid_requester_for_obj
async
Checks if the requested is allowed to view the object
Source code in cattle_grid/activity_pub/actor/__init__.py
remove_from_followers_following
async
remove_from_followers_following(actor_id_to_remove: str)
Removes actor_id from all occurring followers and following
Source code in cattle_grid/activity_pub/actor/__init__.py
update_for_actor_profile
Creates an update for the Actor
Source code in cattle_grid/activity_pub/actor/__init__.py
update_recipients_for_actor
async
Updates set of recipients by removing the followers and following collections, and replacing them with the actual sets.
The following collecting is only allowed for self delete activities.
Source code in cattle_grid/activity_pub/actor/__init__.py
helper
endpoints_object_from_actor_id
Returns the endpoints object of the actor identified by actor_id
>>> endpoints_object_from_actor_id("http://host.test/actor/someId")
{'sharedInbox': 'http://host.test/shared_inbox'}
Source code in cattle_grid/activity_pub/actor/helper.py
shared_inbox_from_actor_id
Returns the shared inbox of the actor identified by actor_id
Source code in cattle_grid/activity_pub/actor/helper.py
identifiers
determine_preferred_username
Determine the preferred username from the sorted identifiers. The result is the name of the first acct-uri whose domain matches the actor id.
>>> determine_preferred_username(["acct:alice@other.example",
... "acct:alice@actor.example"], "http://actor.example/actor")
'alice'
Source code in cattle_grid/activity_pub/actor/identifiers.py
cattle_grid.activity_pub.enqueuer
determine_activity_type
Determines the type of an activity
In the case of multiple types, these are concatenated. This means that they are probably missed by processing, but don’t get ignored.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
activity
|
dict
|
|
required |
Returns:
Type | Description |
---|---|
str | None
|
|
Source code in cattle_grid/activity_pub/enqueuer.py
enqueue_from_inbox
async
enqueue_from_inbox(
broker: RabbitBroker,
exchange: RabbitExchange,
receiving_actor_id: str,
content: dict,
)
Enqueues a new message arrived from the inbox
The routing key will be incoming.${activity_type}
Source code in cattle_grid/activity_pub/enqueuer.py
enqueue_from_shared_inbox
async
enqueue_from_shared_inbox(
broker: RabbitBroker,
exchange: RabbitExchange,
content: dict,
)
Enqueues a new message arrived from the inbox
The routing key will be incoming.${activity_type}