mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-15 03:04:28 +00:00
Tweak the attachment handling for Hubzilla support
This commit is contained in:
parent
4910729b2c
commit
cf46ddcb60
2 changed files with 6 additions and 3 deletions
7
tasks.py
7
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}")
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
<ul>
|
||||
{% endif %}
|
||||
{% for a in obj.attachment %}
|
||||
{% if a.mediaType.startswith("image/") %}
|
||||
{% if (a.mediaType and a.mediaType.startswith("image/")) or (a.type and a.type == 'Image') %}
|
||||
<a href="{{ a.url | get_attachment_url(None) }}"><img src="{{a.url | get_attachment_url(720) }}" class="img-attachment"></a>
|
||||
{% else %}
|
||||
<li><a href="{{a.url }}" class="l">{% if a.filename %}{{ a.filename }}{% else %}{{ a.url }}{% endif %}</a></li>
|
||||
|
|
Loading…
Reference in a new issue