bovine.utils
activity_pub_object_id_from_html_body
Determines the object identifier from the html body by parsing it and looking for link tags with rel=”alternate” and type application/activity+json
Source code in bovine/bovine/utils/__init__.py
check_max_offset_now
Checks that offset of a datetime to now to be less than minutes
Source code in bovine/bovine/utils/__init__.py
get_gmt_now
get_gmt_now() -> str
Returns the current time in UTC as a GMT formatted string as used in the HTTP Date header
now_isoformat
now_isoformat() -> str
Returns now in Isoformat, e.g. “2023-05-31T18:11:35Z”, to be used as the value of published
parse_fediverse_handle
Splits fediverse handle in name and domain Supported forms are:
- user@domain -> (user, domain)
- @user@domain -> (user, domain)
- acct:user@domain -> (user, domain)
Source code in bovine/bovine/utils/__init__.py
parse_gmt
Parses a GMT formatted string as used in HTTP Date header
pydantic_to_json
pydantic_to_json(obj) -> dict
Transforms a pydantic object from bovine.models into a dictionary, that can be serialized as json
webfinger_response
Returns the webfinger response a sa JrdData object
>>> webfinger_response("acct:actor@test.example", "http://test.example/actor")
JrdData(subject='acct:actor@test.example',
expires=None,
aliases=None,
properties=None,
links=[JrdLink(rel='self',
type='application/activity+json',
href='http://test.example/actor',
titles=None,
properties=None,
template=None)])
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account
|
str
|
The acct uri |
required |
url
|
str
|
The URL of the actor object |
required |
Returns:
Type | Description |
---|---|
JrdData
|
|
Source code in bovine/bovine/utils/__init__.py
webfinger_response_json
helper to generate a webfinger response
>>> webfinger_response_json("acct:actor@test.example", "http://test.example/actor")
{'subject': 'acct:actor@test.example',
'links': [{'rel': 'self',
'type': 'application/activity+json',
'href': 'http://test.example/actor'}]}