From cf46ddcb608525089ba7c14afdcac550b9a33167 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Tue, 24 Jul 2018 22:10:39 +0200 Subject: [PATCH] Tweak the attachment handling for Hubzilla support --- tasks.py | 7 +++++-- templates/utils.html | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tasks.py b/tasks.py index ae525ca..1d2cf11 100644 --- a/tasks.py +++ b/tasks.py @@ -48,9 +48,9 @@ def process_new_activity(self, iri: str) -> None: tag_stream = False if activity.has_type(ap.ActivityType.ANNOUNCE): - tag_stream = True try: activity.get_object() + tag_stream = True except NotAnActivityError: # Most likely on OStatus notice tag_stream = False @@ -235,7 +235,10 @@ def cache_attachments(self, iri: str) -> None: if activity.has_type(ap.ActivityType.CREATE): for attachment in activity.get_object()._data.get("attachment", []): - if attachment.get("mediaType", "").startswith("image/"): + if ( + attachment.get("mediaType", "").startswith("image/") + or attachment.get("type") == ap.ActivityType.IMAGE.value + ): MEDIA_CACHE.cache(attachment["url"], Kind.ATTACHMENT) log.info(f"attachments cached for {iri}") diff --git a/templates/utils.html b/templates/utils.html index 1e19cac..6a28002 100644 --- a/templates/utils.html +++ b/templates/utils.html @@ -54,7 +54,7 @@