bovine.activitystreams.object_factory
bovine.activitystreams.object_factory
Object
dataclass
A dataclass representing an ActivityStreams Object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type
|
str
|
|
required |
attributed_to
|
str | None
|
|
None
|
followers
|
str | None
|
|
None
|
id
|
str | None
|
|
None
|
published
|
str | None
|
|
None
|
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
|
List[dict]
|
Built-in mutable sequence. If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified. |
<dynamic>
|
attachment
|
List[dict]
|
Built-in mutable sequence. If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified. |
<dynamic>
|
href
|
str | None
|
|
None
|
icon
|
dict | None
|
|
None
|
media_type
|
str | None
|
|
None
|
digest_multibase
|
str | None
|
|
None
|
file_size
|
str | None
|
|
None
|
duration
|
str | None
|
|
None
|
Source code in bovine/bovine/activitystreams/object_factory.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
as_followers
addresses the object to followers, if they are set
>>> obj = Object(type="Note",
... followers="http://actor.example/followers")
>>> obj.as_followers().build()
{'@context': 'https://www.w3.org/ns/activitystreams',
'type': 'Note',
'to': ['http://actor.example/followers']}
Source code in bovine/bovine/activitystreams/object_factory.py
as_public
makes the object public, i.e. public in to and followers in cc
>>> obj = Object(type="Note",
... followers="http://actor.example/followers")
>>> obj.as_public().build()
{'@context': 'https://www.w3.org/ns/activitystreams',
'type': 'Note',
'to': ['https://www.w3.org/ns/activitystreams#Public'],
'cc': ['http://actor.example/followers']}
Source code in bovine/bovine/activitystreams/object_factory.py
as_unlisted
makes the object unlisted, i.e. public in cc and followers in to
>>> obj = Object(type="Note",
... followers="http://actor.example/followers")
>>> obj.as_unlisted().build()
{'@context': 'https://www.w3.org/ns/activitystreams',
'type': 'Note',
'to': ['http://actor.example/followers'],
'cc': ['https://www.w3.org/ns/activitystreams#Public']}
Source code in bovine/bovine/activitystreams/object_factory.py
build
Returns the resulting object as a dictionary
Source code in bovine/bovine/activitystreams/object_factory.py
ObjectFactory
ObjectFactory usually created through a BovineClient
The property id_generator
can also be supplied similarly to
ActivityFactory.
Source code in bovine/bovine/activitystreams/object_factory.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
|
article
Creates an Article Object
>>> object_factory = ObjectFactory({"id": "http://actor.example"})
>>> object_factory.article(content="Hello World!").build()
{'@context': 'https://www.w3.org/ns/activitystreams',
'type': 'Article',
'attributedTo': 'http://actor.example',
'published': '2024-09-26T18:35:42Z',
'content': 'Hello World!'}
Source code in bovine/bovine/activitystreams/object_factory.py
event
Creates an Event Object
>>> object_factory = ObjectFactory({"id": "http://actor.example"})
>>> object_factory.event(content="Hello World!").build()
{'@context': 'https://www.w3.org/ns/activitystreams',
'type': 'Event',
'attributedTo': 'http://actor.example',
'published': '2024-09-26T18:35:42Z',
'content': 'Hello World!'}
Source code in bovine/bovine/activitystreams/object_factory.py
mention_for_actor_uri
async
Creates a mention object for another actor. Requires client to be set.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
actor_to_mention
|
The URI of the actor to mention |
required |
Source code in bovine/bovine/activitystreams/object_factory.py
note
Creates a Note Object
>>> object_factory = ObjectFactory({"id": "http://actor.example"})
>>> object_factory.note(content="Hello World!").build()
{'@context': 'https://www.w3.org/ns/activitystreams',
'type': 'Note',
'attributedTo': 'http://actor.example',
'published': '2024-09-26T18:35:42Z',
'content': 'Hello World!'}
For automatic addressing use for example as_public
>>> object_factory = ObjectFactory({"id": "http://actor.example",
... "followers": "http://actor.example/followers"})
>>> object_factory.note(content="Hello World!").as_public().build()
{'@context': 'https://www.w3.org/ns/activitystreams',
'type': 'Note',
'attributedTo': 'http://actor.example',
'to': ['https://www.w3.org/ns/activitystreams#Public'],
'cc': ['http://actor.example/followers'],
'published': '2024-09-26T18:35:42Z',
'content': 'Hello World!'}
Source code in bovine/bovine/activitystreams/object_factory.py
reply
reply(obj: dict, **kwargs)
Creates a reply for an object. Reply is addressed to the author of object. Other recipients are set as cc.
>>> obj = Object(type="Note", attributed_to="http://other.example",
... to={"http://other.example/followers"},
... cc={"http://alice.example", "http://actor.example"}).build()
>>> obj
{'@context': 'https://www.w3.org/ns/activitystreams',
'type': 'Note',
'attributedTo': 'http://other.example',
'to': ['http://other.example/followers'],
'cc': ['http://actor.example', 'http://alice.example']}
>>> object_factory = ObjectFactory({"id": "http://actor.example"})
>>> object_factory.reply(obj).build()
{'@context': 'https://www.w3.org/ns/activitystreams',
'type': 'Note',
'attributedTo': 'http://actor.example',
'to': ['http://other.example'],
'cc': ['http://alice.example', 'http://other.example/followers'],
'published': '2024-09-26T18:35:42Z'}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
dict
|
Object being replied to |
required |
Source code in bovine/bovine/activitystreams/object_factory.py
reply_with_mention
async
reply_with_mention(obj: dict, **kwargs)
Creates a reply for an object, mentioning the author of the original post. This is necessary for compatibility with Mastodon
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
dict
|
Object being replied to |
required |