diff --git a/activitypub.py b/activitypub.py index b5ed7c9..55ba6ce 100644 --- a/activitypub.py +++ b/activitypub.py @@ -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)