bovine.activitystreams

class bovine.activitystreams.Actor(id: str, type: str = 'Person', name: str | None = None, preferred_username: str | None = None, inbox: str | None = None, outbox: str | None = None, followers: str | None = None, following: str | None = None, public_key: str | None = None, public_key_name: str | None = None, event_source: str | None = None, proxy_url: str | None = None, summary: str | None = None, icon: dict | None = None, url: str | None = None)[source]

Actor class represents the basic ActivityStreams actor.

build(visibility=Visibility.PUBLIC)[source]

Creates the json-ld representation of the actor.

class bovine.activitystreams.Collection(id: str, items: list)[source]
class bovine.activitystreams.OrderedCollection(id: str, items: list | None = None, count: int = 0, first: str | None = None, last: str | None = None)[source]
class bovine.activitystreams.OrderedCollectionPage(id: str, items: list, part_of: str, next: str | None = None, prev: str | None = None)[source]
bovine.activitystreams.factories_for_actor_object(actor_object: dict) Tuple[ActivityFactory, ObjectFactory][source]

Builds activity and object factories from actor object

class bovine.activitystreams.activity_factory.Activity(type: str, actor: str | None = None, followers: str | None = None, id: str | None = None, published: str | None = None, to: ~typing.Set[str] = <factory>, cc: ~typing.Set[str] = <factory>, name: str | None = None, summary: str | None = None, content: str | None = None, target: str | None = None, object: str | None = None)[source]

A dataclass representing an ActivityStreams Activity

as_followers()[source]

addresses the activity to followers, if they are set

as_public()[source]

makes the activity public, i.e. public in to and followers in cc

as_unlisted()[source]

makes the activity unlisted, i.e. public in cc and followers in to

build() dict[source]

converts the activity into a dict, that can be serialized to JSON

class bovine.activitystreams.activity_factory.ActivityFactory(actor_information)[source]

Basic factory for Activity objects.

Usally created by a BovineClient

accept(obj, **kwargs)[source]

Accept for object

announce(obj, **kwargs)[source]

Announce for object

create(obj, **kwargs)[source]

Activity of type Create from Object

delete(target, **kwargs)[source]

Delete for target

follow(obj, **kwargs)[source]

Follow for object

like(target, **kwargs)[source]

Like for target

reject(obj, **kwargs)[source]

Reject for object

undo(activity, **kwargs)[source]

Undo for activity

update(obj, **kwargs)[source]

Activity of type Update from Object

class bovine.activitystreams.object_factory.Object(type: str, attributed_to: str | None = None, followers: str | None = None, id: str | None = None, published: str | None = None, to: ~typing.Set[str] = <factory>, cc: ~typing.Set[str] = <factory>, name: str | None = None, summary: str | None = None, content: str | None = None, source: dict | None = None, width: int | None = None, height: int | None = None, in_reply_to: str | None = None, url: str | None = None, tag: ~typing.List[dict] = <factory>, attachment: ~typing.List[dict] = <factory>, href: str | None = None, icon: dict | None = None, media_type: str | None = None)[source]

A dataclass representing an ActivityStreams Object

as_followers()[source]

addresses the object to followers, if they are set

as_public()[source]

makes the object public, i.e. public in to and followers in cc

as_unlisted()[source]

makes the object unlisted, i.e. public in cc and followers in to

build()[source]

Returns the resulting object as a dictionary

now()[source]

Sets published to now in isoformat

class bovine.activitystreams.object_factory.ObjectFactory(actor_information=None, client=None)[source]

ObjectFactory usually created through a BovineClient

article(**kwargs)[source]

Creates an Article Object

event(**kwargs)[source]

Creates an Event Object

async mention_for_actor_uri(actor_to_mention)[source]

Creates a mention object for another actor. Requires client to be set.

Parameters:

actor_to_mention – The URI of the actor to mention

note(**kwargs)[source]

Creates a Note Object

reply(obj, **kwargs)[source]

Creates a reply for an object

class bovine.activitystreams.collection_helper.CollectionHelper(collection_id: str, actor, resolve=False)[source]

Provides the ability to iterate over a Collection or OrderedCollection

Usage:

async for item in CollectionHelper(collection_id, bovine_client):
    do_something(item)

By setting resolve=True, items are always returned as a dictinary. Otherwise, they are returned as a string or dictionary depending on how the data is provided by the remote server.

async as_collection() dict[source]

Returns an ActivityStreams collection containing the items represented by the collection_id. This is useful for collections spread over multiple pages

bovine.activitystreams.utils.actor_for_object(data: dict) str[source]

Look up for the actor id either from attributedTo or actor

bovine.activitystreams.utils.copy_to_and_cc(origin: dict, destination: dict) dict[source]

Copies the audience from the origin object to the destination object

bovine.activitystreams.utils.fediverse_handle_from_actor(actor: dict) str[source]

Given an actor object, i.e. a dict, determines the fediverse handle

bovine.activitystreams.utils.id_for_object(data: dict | str | None) str | None[source]

Determines the id of an object

bovine.activitystreams.utils.is_public(data: dict) bool[source]

Determines if the object should be considered public based on its recipients

bovine.activitystreams.utils.recipients_for_object(data: dict) set[source]

Combines the recipients from to, cc, bto, bcc, audience into a set