.activity_pub¶
For public methods see here.
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 ¶
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(
session: AsyncSession, 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(
session: AsyncSession,
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(session: AsyncSession, 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
remove_from_followers_following
async
¶
remove_from_followers_following(
session: AsyncSession, 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
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
relationship ¶
followers_for_actor
async
¶
followers_for_actor(
session: AsyncSession, actor: Actor
) -> Sequence[str]
following_for_actor
async
¶
following_for_actor(
session: AsyncSession, actor: Actor
) -> Sequence[str]
Returns the list of accepted people to follow said actor. This is the following table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
actor
|
Actor
|
|
required |
Returns:
Type | Description |
---|---|
Sequence[str]
|
|
Source code in cattle_grid/activity_pub/actor/relationship.py
is_blocked
async
¶
is_blocked(
session: AsyncSession,
actor: Actor,
remote_actor_id: str,
) -> bool
Checks if remote_actor_id is blocked by actor
Source code in cattle_grid/activity_pub/actor/relationship.py
requester ¶
ActorNotFound ¶
is_valid_requester
async
¶
is_valid_requester(
session: AsyncSession,
requester: str,
actor: Actor,
obj: dict,
)
Checks if the requested is allowed to view the object
FIXME tests in test_actor?
Source code in cattle_grid/activity_pub/actor/requester.py
is_valid_requester_for_obj
async
¶
is_valid_requester_for_obj(
session: AsyncSession, requester: str, obj: dict
)
Checks if the requested is allowed to view the object
Source code in cattle_grid/activity_pub/actor/requester.py
update_recipients_for_actor
async
¶
update_recipients_for_actor(
session: AsyncSession,
actor: Actor,
recipients,
self_delete=False,
)
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/requester.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}