Pre-cache the attachments
This commit is contained in:
parent
3281e2165e
commit
8ffeb1fe4f
1 changed files with 10 additions and 0 deletions
|
@ -18,6 +18,8 @@ from config import ID
|
|||
from config import ME
|
||||
from config import USER_AGENT
|
||||
from config import USERNAME
|
||||
from config import MEDIA_CACHE
|
||||
from utils.media import Kind
|
||||
from little_boxes import activitypub as ap
|
||||
from little_boxes import strtobool
|
||||
from little_boxes.activitypub import _to_list
|
||||
|
@ -87,6 +89,14 @@ class MicroblogPubBackend(Backend):
|
|||
}
|
||||
)
|
||||
|
||||
# Generates thumbnails for the actor's icon and the attachments if any
|
||||
actor = activity.get_actor()
|
||||
if actor.icon:
|
||||
MEDIA_CACHE.cache(actor.icon["url"], Kind.ACTOR_ICON)
|
||||
if activity.type == ap.ActivityType.CREATE.value:
|
||||
for attachment in activity.get_object()._data.get("attachment", []):
|
||||
MEDIA_CACHE.cache(attachment["url"], Kind.ATTACHMENT)
|
||||
|
||||
@ensure_it_is_me
|
||||
def outbox_new(self, as_actor: ap.Person, activity: ap.BaseActivity) -> None:
|
||||
self.save(Box.OUTBOX, activity)
|
||||
|
|
Loading…
Reference in a new issue